Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullable slash command arguments throw DSharpPlus.Commands.Exceptions.ArgumentParseException #1864

Closed
ecrocombe opened this issue Apr 30, 2024 · 2 comments · Fixed by #1897
Closed
Labels
bug commands For issues related to DSharpPlus.Commands
Milestone

Comments

@ecrocombe
Copy link
Contributor

Summary

Nullable slash command arguments in DSharpPlus.Commands fire DiscordClient.CommandErrored event under certain conditions with "DSharpPlus.Commands.Exceptions.ArgumentParseException: Argument Converter for type DSharpPlus.Entities.DiscordChannel was unable to parse the argument."

What version of the library are you using?

v5.0.0-nightly (make sure you are using the latest nightly!)

What .NET version are you using? Make sure to use the latest patch release for your major version.

.NET 8.0

Operating System

Ubuntu 22.04

Reproduction Steps

Using the below as an example, specify gameserver and the optional prefix and suffix arguments, but do not specify voice-channel.

[Command("onlinechannel")]
[Description("Assign a voice channel to display the number online")]
[RequirePermissions(botPermissions: DiscordPermissions.None, userPermissions: DiscordPermissions.ManageGuild)]
public async Task SetOnlineChannel
(
SlashCommandContext ctx,

[Parameter("gameserver")]
[Description("Choose the gameserver to modify")]
[SlashAutoCompleteProvider<GameserverAutocompleteHandler>]
int gameserverId,

[Parameter("voice-channel")]
[Description( "Choose the voice channel to rename with the player count")]
[SlashChannelTypes(DiscordChannelType.Voice)]
DiscordChannel? voiceChannel = null,

[Parameter("prefix")]
[Description("The text to display before the number of players in the voice channel name")]
string? prefix = null,

[Parameter("suffix")]
[Description("The text to display after the number of players in the voice channel name")]
string? suffix = null
)

Trace Logs

[17:57:55 VRB] Discord CommandErrored: Message: Argument Converter for type DSharpPlus.Entities.DiscordChannel was unable to parse the argument. : StackTrace: null

Exceptions or other error messages

17:57:55 WRN] Discord CommandErrored
DSharpPlus.Commands.Exceptions.ArgumentParseException: Argument Converter for type DSharpPlus.Entities.DiscordChannel was unable to parse the argument.

Anything else you'd like to share

No response

@ecrocombe ecrocombe added the bug label Apr 30, 2024
@akiraveliara akiraveliara added the commands For issues related to DSharpPlus.Commands label Apr 30, 2024
@akiraveliara akiraveliara added this to the v5.0 milestone Apr 30, 2024
@ecrocombe
Copy link
Contributor Author

possible duplicate of #1843

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug commands For issues related to DSharpPlus.Commands
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants