Added ..qdel, stop crying now ;p

This commit is contained in:
Master Kwoth 2016-05-21 16:15:02 +02:00
parent c7a83aa58a
commit 98d166e539

View File

@ -2,6 +2,7 @@ using Discord;
using Discord.Commands;
using Discord.Modules;
using NadekoBot.Classes.Conversations.Commands;
using NadekoBot.DataModels;
using NadekoBot.Extensions;
using NadekoBot.Modules.Permissions.Classes;
using NadekoBot.Properties;
@ -73,6 +74,25 @@ namespace NadekoBot.Modules.Conversations
else
await e.Channel.SendMessage("💢`No quote found.`").ConfigureAwait(false);
});
cgb.CreateCommand("..qdel")
.Description("Deletes all quotes with the specified keyword. You have to either be bot owner or the creator of the quote to delete it.\n**Usage**: `..qdel abc`")
.Parameter("quote", ParameterType.Required)
.Do(async e =>
{
var text = e.GetArg("quote")?.Trim();
if (string.IsNullOrWhiteSpace(text))
return;
await Task.Run(() =>
{
if (NadekoBot.IsOwner(e.User.Id))
Classes.DbHandler.Instance.DeleteWhere<UserQuote>(uq => uq.Keyword == text);
else
Classes.DbHandler.Instance.DeleteWhere<UserQuote>(uq => uq.Keyword == text && uq.UserName == e.User.Name);
}).ConfigureAwait(false);
await e.Channel.SendMessage("`Done.`").ConfigureAwait(false);
});
});
manager.CreateCommands(NadekoBot.BotMention, cgb =>