Update bulk-overwrite-of-global-slash-commands.md

Co-Authored-By: Cookiezzz <2996654+Cookiezzz@users.noreply.github.com>
This commit is contained in:
quin lynch
2022-01-10 20:11:43 -04:00
parent 4b7cda01a6
commit 99d8ca4b6b

View File

@@ -6,10 +6,10 @@ title: Slash Command Bulk Overwrites
If you have too many global commands then you might want to consider using the bulk overwrite function. If you have too many global commands then you might want to consider using the bulk overwrite function.
```cs ```cs
public async Task Client_Ready() public async Task Client_Ready()
{ {
List<ApplicationCommandProperties> applicationCommandProperties = new(); List<ApplicationCommandProperties> applicationCommandProperties = new();
try try
{ {
// Simple help slash command. // Simple help slash command.
SlashCommandBuilder globalCommandHelp = new SlashCommandBuilder(); SlashCommandBuilder globalCommandHelp = new SlashCommandBuilder();
@@ -27,11 +27,12 @@ public async Task Client_Ready()
SlashCommandBuilder globalCommandAddFamily = new SlashCommandBuilder(); SlashCommandBuilder globalCommandAddFamily = new SlashCommandBuilder();
globalCommandAddFamily.WithName("add-family"); globalCommandAddFamily.WithName("add-family");
globalCommandAddFamily.WithDescription("Add a family"); globalCommandAddFamily.WithDescription("Add a family");
globalCommandAddFamily.AddOptions(slashCommandOptionBuilder);
applicationCommandProperties.Add(globalCommandAddFamily.Build()); applicationCommandProperties.Add(globalCommandAddFamily.Build());
await _client.BulkOverwriteGlobalApplicationCommandsAsync(applicationCommandProperties.ToArray()); await _client.BulkOverwriteGlobalApplicationCommandsAsync(applicationCommandProperties.ToArray());
} }
catch (ApplicationCommandException exception) catch (ApplicationCommandException exception)
{ {
var json = JsonConvert.SerializeObject(exception.Error, Formatting.Indented); var json = JsonConvert.SerializeObject(exception.Error, Formatting.Indented);
Console.WriteLine(json); Console.WriteLine(json);