Discord.Net
Discord.Net copied to clipboard
Creating commands returns error 20001
Hello, I was recently making a ticket bot and I wanted to make commands, I wrote the code, but it was returning error 20001 and I can't fix it, please help!
Code:
public async Task Create()
{
List<ApplicationCommandProperties> applicationCommandProperties = new List<ApplicationCommandProperties>();
var close = new SlashCommandBuilder()
.WithName("close")
.WithDescription("Close current ticket you are in")
.WithDefaultMemberPermissions(GuildPermission.ManageMessages)
.WithDMPermission(false)
.WithDefaultPermission(true)
.AddOption(new SlashCommandOptionBuilder()
.WithName("reason")
.WithDescription("Reason for closing ticket")
.WithType(ApplicationCommandOptionType.String)
.WithRequired(false)
);
var perfomance = new SlashCommandBuilder()
.WithName("perfomance")
.WithDescription("Check perfomance of bot such as Ping, RAM Usage and more!")
.WithDefaultPermission(true)
.WithDMPermission(true);
applicationCommandProperties.Add(close.Build());
applicationCommandProperties.Add(perfomance.Build());
try
{
// Now that we have our builder, we can call the CreateApplicationCommandAsync method to make our slash command.
await Program.client.BulkOverwriteGlobalApplicationCommandsAsync(applicationCommandProperties.ToArray());
}
catch (HttpException exception)
{
// If our command was invalid, we should catch an ApplicationCommandException. This exception contains the path of the error as well as the error message. You can serialize the Error field in the exception to get a visual of where your error is.
Console.WriteLine(exception.Message);
}
}
I suspect you're executing this call before the REST client is fully ready. Please move this code to the DiscordSocketClient.Ready event and see if that works.
Could you follow up? Has the issue been resolved?
I suspect you're executing this call before the REST client is fully ready. Please move this code to the DiscordSocketClient.Ready event and see if that works.
Alright, I will try
Any updates?
Closing by lack of followup.