NetCord
NetCord copied to clipboard
Guidance on registering slash commands per guild with NetCord.Hosting.Services
Description
This change has broken the ability to register slash commands using the SlashCommandAttribute on a per guild basis. I currently follow this guidance in your docs alongside custom bases for registering http interaction commands using annotations.
What is the preferred way to register http interactions on a per guild basis to allow for "local" testing?
Hi, I think we might think of explaining how to register app commands to guilds (cc @Mewyk). For now you can see this example:
var services = host.Services;
var service = services.GetRequiredService<ApplicationCommandService<HttpApplicationCommandContext>>();
var client = services.GetRequiredService<RestClient>();
var properties = await Task.WhenAll(service.GetCommands().Where(c => c.Name is not ("some" or "filter" or "if" or "needed")).Select(c => c.GetRawValueAsync().AsTask()));
ulong guildId = 856183259972763669;
await client.BulkOverwriteGuildApplicationCommandsAsync(((IEntityToken)client.Token!).Id, guildId, properties);
Also you will probably want to set AutoRegisterCommands to false in the configuration.
That said, I think local testing should be done on a separate Discord application (bot).