The arguments seem to be passed to the command in the order they are defined, regardless of which are actually sent from discord.
In the discord UI, I set title, description, image.
The command handler assigned those to content, title, description
Full file for that group:
using System.Net.Mime;
using System.Threading.Tasks;
using DSharpPlus;
using DSharpPlus.Entities;
using DSharpPlus.SlashCommands;
public partial class SlashModule : SlashCommandModule
{
[SlashCommandGroup("message", "Send a message")]
public class MessageGroup
{
[SlashCommand("embed", "Embed a message")]
public async Task MessageEmbed(
InteractionContext ctx,
[Option("Content", "The plain text content of the embed")]
string content = null,
[Option("Title", "The title of the embed")]
string title = null,
[Option("Description", "The description of the embed")]
string description = null,
[Option("Thumbnail", "The thumbnail of the embed")]
string thumbnail = null,
[Option("Image", "The image on the bottom of the embed")]
string image = null)
{
if (((await ctx.Guild.GetMemberAsync(ctx.Client.CurrentUser.Id)).PermissionsIn(ctx.Channel) &
Permissions.SendMessages) == 0)
{
await ctx.CreateResponseAsync(
InteractionResponseType.ChannelMessageWithSource,
new DiscordInteractionResponseBuilder()
.AsEphemeral(true)
.WithContent("I can't send messages in that channel")
);
}
var embedBuilder = new DiscordEmbedBuilder();
if (title is not null)
embedBuilder.WithTitle(title);
if (description is not null)
embedBuilder.WithDescription(description);
if (thumbnail is not null)
embedBuilder.WithThumbnail(thumbnail);
if (image is not null)
embedBuilder.WithImageUrl(image);
if (content is not null)
await ctx.Channel.SendMessageAsync(content, embedBuilder.Build());
else
await ctx.Channel.SendMessageAsync(embedBuilder.Build());
await ctx.CreateResponseAsync(
InteractionResponseType.ChannelMessageWithSource,
new DiscordInteractionResponseBuilder()
.AsEphemeral(true)
.WithContent("Sent!"));
}
}
}
DSharpPlus 4.0.1 DSharpPlus.SlashCommands 1.2.2
The arguments seem to be passed to the command in the order they are defined, regardless of which are actually sent from discord.
In the discord UI, I set
title
,description
,image
. The command handler assigned those tocontent
,title
,description
Full file for that group: