add def lookup for missing commands

This commit is contained in:
Ben Harris 2017-12-05 12:10:21 -05:00
parent 708bf7409e
commit 323d17e89d
1 changed files with 14 additions and 0 deletions

View File

@ -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)}");
}
}
}
}
}
}