From 323d17e89d039b66f417cd6ead8068d96cd3b71c Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Tue, 5 Dec 2017 12:10:21 -0500 Subject: [PATCH] add def lookup for missing commands --- Services/CommandHandlerService.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Services/CommandHandlerService.cs b/Services/CommandHandlerService.cs index 89a4f34..3be84cd 100644 --- a/Services/CommandHandlerService.cs +++ b/Services/CommandHandlerService.cs @@ -3,6 +3,8 @@ using Discord.WebSocket; using Microsoft.Extensions.Configuration; using System; using System.Threading.Tasks; +using dotbot.Core; +using System.Linq; namespace dotbot.Services { @@ -44,6 +46,18 @@ namespace dotbot.Services if (!result.IsSuccess) // If not successful, reply with the error. await context.Channel.SendMessageAsync(result.ToString()); } + else + { + using (var db = new DotbotDbContext()) + { + if (msg.HasStringPrefix(_config["prefix"], ref argPos)) + { + var key = msg.Content.Substring(_config["prefix"].Length); + if (db.Defs.Any(d => d.Id == key)) + await context.Channel.SendMessageAsync($"**{key}**: {db.Defs.Find(key)}"); + } + } + } } } }