prevent command spam when we have interactive prompt and the user uses another command instead

This commit is contained in:
13xforever 2019-03-20 18:45:56 +05:00
parent 754c25d4de
commit 0138d54ed0
2 changed files with 3 additions and 3 deletions

View File

@ -47,7 +47,7 @@ namespace CompatBot.Commands
var prompt = await ctx.RespondAsync($"{ctx.Message.Author.Mention} what game do you want to check?").ConfigureAwait(false);
var interact = ctx.Client.GetInteractivity();
var response = await interact.WaitForMessageAsync(m => m.Author == ctx.Message.Author && m.Channel == ctx.Channel).ConfigureAwait(false);
if (string.IsNullOrEmpty(response?.Message?.Content))
if (string.IsNullOrEmpty(response?.Message?.Content) || response.Message.Content.StartsWith(Config.CommandPrefix))
{
await prompt.ModifyAsync("You should specify what you're looking for").ConfigureAwait(false);
return;

View File

@ -34,7 +34,7 @@ namespace CompatBot.Commands
var sourceTerm = term;
if (string.IsNullOrEmpty(term))
{
var botMsg = await ctx.RespondAsync("Please specify term to explain").ConfigureAwait(false);
var botMsg = await ctx.RespondAsync("Please tell what term to explain:").ConfigureAwait(false);
var lastBotMessages = await ctx.Channel.GetMessagesBeforeAsync(ctx.Message.Id, 10).ConfigureAwait(false);
var showList = true;
foreach (var pastMsg in lastBotMessages)
@ -50,7 +50,7 @@ namespace CompatBot.Commands
var interact = ctx.Client.GetInteractivity();
var newMessage = await interact.WaitForMessageAsync(m => m.Author == ctx.User && m.Channel == ctx.Channel && !string.IsNullOrEmpty(m.Content)).ConfigureAwait(false);
await botMsg.DeleteAsync().ConfigureAwait(false);
if (string.IsNullOrEmpty(newMessage?.Message?.Content))
if (string.IsNullOrEmpty(newMessage?.Message?.Content) || newMessage.Message.Content.StartsWith(Config.CommandPrefix))
{
await ctx.ReactWithAsync(Config.Reactions.Failure).ConfigureAwait(false);
return;