Skip to content

Using Mention in the WebHookBuilder throws a bad request #1325

@Hax1337

Description

@Hax1337

Make sure you familiarize yourself with our contributing guidelines.

Summary

When using
interactionEvent.Interaction.CreateResponseAsync(InteractionResponseType.DeferredChannelMessageWithSource)

and then trying to edit via the webookBuilder and adding mentions, I get the error:
Bad request 400

Inner exception:
"{\r\n "allowed_mentions": {\r\n "_errors": [\r\n {\r\n "code": "MODEL_TYPE_CONVERT",\r\n "message": "Only dictionaries may be used in a ModelType"\r\n }\r\n ]\r\n }\r\n}"

Details

Environment: VS2022
Framework: .NET 4.7.2
DSharpPlus Version: 4.3.0-nightly-01143
OS: Windows 11

  • Create a message with a button to interact
  • Create a method inteeracting with the button and use:
    interactionEvent.Interaction.CreateResponseAsync(InteractionResponseType.DeferredChannelMessageWithSource)
  • Then create a WeebHookBuilder and add a RoleMention + some content to respond.
try
{
interactionEvent.Interaction.CreateResponseAsync(InteractionResponseType.DeferredChannelMessageWithSource).Wait();
Thred.Sleep(10000);  //some operation happening

DiscordWebhookBuilder webhook = new DiscordWebhookBuilder();

                            DiscordRole role = interactionEvent.Interaction.Guild.GetRole(YOURROLEID);
                            webhook.AddMention(new RoleMention(role));
                            webhook.WithContent("Hello its me");
                            interactionEvent.Interaction.EditOriginalResponseAsync(webhook).Wait();
}
catch (Exception ex)
{
console.writelIne(ex.toString());
}

Steps to reproduce

  1. Click the button you created
  2. Wait for the error

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions