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

[Commands] Autocomplete provider throws null reference if command has user parameter #1783

Closed
BlackLotusLV opened this issue Feb 25, 2024 · 0 comments · Fixed by #1792
Closed
Labels
bug commands For issues related to DSharpPlus.Commands
Milestone

Comments

@BlackLotusLV
Copy link

Summary

If a slash command has a parameter DiscordUser and is followed by a auto complete provider, whenever you select to fill out the auto fill field on discord, it throws an null reference error.

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

Win11

Reproduction Steps

Make a slash command that contains a DiscordUser followed by an auto complete provider
example

[Command("unwarn"), Description("Removes a warning from the user"), RequirePermissions(Permissions.KickMembers)]
public async Task UnWarn(SlashCommandContext ctx,
    [Description("User to remove the warning for")] DiscordUser user,
    [Description("The ID of a specific warning. Leave as is if don't want a specific one"), SlashAutoCompleteProvider(typeof(ActiveWarningAutocompleteProvider))] long warningId = -1)

On discord, try to fill out the command, when you try to input the autocomplete field, it will throw an error

Trace Logs

[2024:02:25 13:26:23 ERR] [202|CMDError    ] blacklotus(86725763428028416) tried executing 'Mod unwarn' command, but it errored
DSharpPlus.Commands.Exceptions.ArgumentParseException: Failed to parse user.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at DSharpPlus.Commands.Converters.DiscordUserConverter.ConvertAsync(ConverterContext context, InteractionCreateEventArgs eventArgs)
   at DSharpPlus.Commands.Processors.BaseCommandProcessor`4.ExecuteConverterAsync[T](TConverter converter, TConverterContext converterContext, TEventArgs eventArgs)
   at DSharpPlus.Commands.Processors.SlashCommands.SlashCommandProcessor.ParseAutoCompleteArgumentsAsync(InteractionConverterContext converterContext, InteractionCreateEventArgs eventArgs)
   --- End of inner exception stack trace ---

Exceptions or other error messages

No response

Anything else you'd like to share

No response

@Plerx2493 Plerx2493 added the commands For issues related to DSharpPlus.Commands label Feb 25, 2024
@akiraveliara akiraveliara added this to the v5.0 milestone Feb 25, 2024
@akiraveliara akiraveliara linked a pull request Mar 7, 2024 that will close this issue
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.

3 participants