Button Interactions produce a 404 not found when AckPagination is true in Interactivity config
Created by: villChurch
Summary
A NotFoundException
happens when a non pagination related button interaction happens when AckPagniation = true
in InteractivityConfiguration
. This means a user can either use buttons only with the built in pagination methods or set AckPagniation = false
and then normal buttons work but the pagination ones return interaction failed.
Details
DSharpPlusVersion - 4.1.0-nightly-00948 running on .NET 5.0.2
Example Command to reproduce issue.
[Command("tb")]
public async Task TestButtonCommand(CommandContext ctx)
{
var myButton = new DiscordButtonComponent(ButtonStyle.Primary, "my_very_cool_button", "Very cool button!",
false, new DiscordComponentEmoji("😀"));
var builder = new DiscordMessageBuilder();
builder.WithContent("This message has buttons! Pretty neat innit?");
builder.AddComponents(myButton);
var msg = await builder.SendAsync(ctx.Channel);
var interactivity = ctx.Client.GetInteractivity();
var buttonComponents = new List<DiscordButtonComponent> {myButton};
IEnumerable<DiscordButtonComponent> buttonEnum = buttonComponents;
var result = await interactivity.WaitForButtonAsync(msg, buttonEnum, TimeSpan.FromMinutes(1));
var interaction = result.Result;
await interaction.Interaction.CreateResponseAsync(InteractionResponseType.UpdateMessage,
new DiscordInteractionResponseBuilder()
.WithContent($"{result.Result.User.Mention} pressed the button first")
.AddComponents(myButton)).ConfigureAwait(false);
}
Example InteractivityConfiguration
Client.UseInteractivity(new InteractivityConfiguration
{
PaginationBehaviour = PaginationBehaviour.WrapAround,
Timeout = TimeSpan.FromMinutes(1),
ButtonBehavior = ButtonPaginationBehavior.Disable,
AckPaginationButtons = true,
PaginationButtons = new PaginationButtons(),
PaginationEmojis = new PaginationEmojis(),
PaginationDeletion = PaginationDeletion.DeleteEmojis
});
Stacktrace for the above code
[2021-08-04 13:41:52 +01:00] [0 / ] [Error] User tried executing 'tb' but it errored: DSharpPlus.Exceptions.NotFoundException: Not found: 404, Stacktrace at DSharpPlus.Net.DiscordApiClient.CreateInteractionResponseAsync(UInt64 interaction_id, String interaction_token, InteractionResponseType type, DiscordInteractionResponseBuilder builder)
at BumbleBot.Commands.ButtonCommands.TestButtonCommands.TestButtonCommand(CommandContext ctx) in /Users/.../Desktop/TestBot/TestBot/Commands/ButtonCommands/TestButtonCommands.cs:line 67
at DSharpPlus.CommandsNext.Command.ExecuteAsync(CommandContext ctx)
Line 67 of TestButtonCommand.cs
await interaction.Interaction.CreateResponseAsync(InteractionResponseType.UpdateMessage,
new DiscordInteractionResponseBuilder()
.WithContent($"{result.Result.User.Mention} pressed the button first")
.AddComponents(myButton)).ConfigureAwait(false);
Steps to reproduce
- Set AckPaginationButtons = true in InteractivityConfiguartion
- Create a command that uses a button and uses
WaitForButtonAsync
to respond to the button - Start bot and try clicking the button
Notes
Had a look around myself and think it could be related to this part of the code which seems to acknowledge any interaction regardless of if it came from pagination.
When AckPagination = false
in InteractivityConfiguration buttons work as expect but then pagination using buttons returns invalid interaction for each pagination interaction.