fix potential issues with interactive stuff where it could pick up messages from another channel

This commit is contained in:
13xforever 2019-03-06 21:24:26 +05:00
parent f1e5f2bce7
commit e0aa6110b9
4 changed files with 4 additions and 4 deletions

View File

@ -46,7 +46,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).ConfigureAwait(false);
var response = await interact.WaitForMessageAsync(m => m.Author == ctx.Message.Author && m.Channel == ctx.Channel).ConfigureAwait(false);
if (string.IsNullOrEmpty(response?.Message?.Content))
{
await prompt.ModifyAsync("You should specify what you're looking for").ConfigureAwait(false);

View File

@ -48,7 +48,7 @@ namespace CompatBot.Commands
if (showList)
await List(ctx).ConfigureAwait(false);
var interact = ctx.Client.GetInteractivity();
var newMessage = await interact.WaitForMessageAsync(m => m.Author == ctx.User && !string.IsNullOrEmpty(m.Content)).ConfigureAwait(false);
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))
{

View File

@ -30,7 +30,7 @@ namespace CompatBot.Commands
{
var botMsg = await ctx.RespondAsync("Please specify a valid product code (e.g. BLUS12345 or NPEB98765)").ConfigureAwait(false);
var interact = ctx.Client.GetInteractivity();
var msg = await interact.WaitForMessageAsync(m => m.Author == ctx.User && !string.IsNullOrEmpty(m.Content)).ConfigureAwait(false);
var msg = await interact.WaitForMessageAsync(m => m.Author == ctx.User && m.Channel == ctx.Channel && !string.IsNullOrEmpty(m.Content)).ConfigureAwait(false);
await botMsg.DeleteAsync().ConfigureAwait(false);
id = ProductCodeLookup.GetProductIds(msg.Message?.Content).FirstOrDefault();

View File

@ -28,7 +28,7 @@ namespace CompatBot.Utils
reactions = reactions.Where(r => r != null).ToArray();
foreach (var emoji in reactions)
await message.ReactWithAsync(interactivity.Client, emoji).ConfigureAwait(false);
var waitTextResponseTask = interactivity.WaitForMessageAsync(m => m.Author == user && !string.IsNullOrEmpty(m.Content), timeout);
var waitTextResponseTask = interactivity.WaitForMessageAsync(m => m.Author == user && m.Channel == message.Channel && !string.IsNullOrEmpty(m.Content), timeout);
var waitReactionResponse = interactivity.WaitForMessageReactionAsync(reactions.Contains, message, user, timeout);
await Task.WhenAny(
waitTextResponseTask,