Discord.Net icon indicating copy to clipboard operation
Discord.Net copied to clipboard

NRE on SlashCommandBuilder.Build

Open 9True opened this issue 2 years ago • 3 comments

Check The Docs

  • [X] I double checked the docs and couldn't find any useful information.

Verify Issue Source

  • [X] I verified the issue was caused by Discord.Net.

Check your intents

  • [X] I double checked that I have the required intents.

Description

Hi, I updated Discord.Net to 3.8.0, and now I can't add / update my slash commands. Worked on 3.3.0. I even tried to do exactly like the tutorial in the documention, but I'm still getting the same error.

Version

3.8.0

Working Version

3.3.0

Logs

Exception thrown: 'System.NullReferenceException' in Discord.Net.Core.dll Object reference not set to an instance of an object. at Discord.ApplicationCommandProperties.set_NameLocalizations(IReadOnlyDictionary`2 value) at Discord.SlashCommandBuilder.Build()

Sample

var globalCommand = new SlashCommandBuilder(); globalCommand.WithName("first-global-command"); globalCommand.WithDescription("This is my first global slash command"); await client.CreateGlobalApplicationCommandAsync(globalCommand.Build());

Packages

Newtonsoft

9True avatar Aug 30 '22 19:08 9True

This issue is known, will be fixed in the next patch. Only affects global command creation.

Cenngo avatar Aug 30 '22 19:08 Cenngo

I tried both global and guild commands, both have the same issue.

But I got it to work in the meantime. I added: globalCommand.WithNameLocalizations(nameLocales); globalCommand.WithDescriptionLocalizations(descLocales);

Where nameLocales and descLocales are Dictionary<string, string>. Ex: descLocales.Add("en-US", "This is my first global slash command");

9True avatar Aug 30 '22 19:08 9True

Can confirm, global and guild slash command creation still both generate a NRE. The solution of OP did not work for me though unfortunately.

Kirschi94 avatar Sep 02 '22 17:09 Kirschi94