#Better way on removing commands?

1 messages · Page 1 of 1 (latest)

stark fog
#

Hey guys, I normally use
DeleteAllGlobalCommandsAsync()
to remove all commands
Is there a method to remove only specific ones? like i want to remove all user commands?

flat sinew
#
var commands = await DiscordSocketClient.Rest.Get(Guild|Global)ApplicationCommands()
foreach(var cmd in commands.Where(x => .....))
  await cmd.DeleteAsync();
#

something like that

#

that just deletes commands...
alternatively you could do BulkOverwrite(Guild|Global)Commands

merry ermine
#

I actually created a method for html requests to delete a single command :)

#
// deletes single slash command
private async Task DeleteSlashCommand(ulong applicationId, ulong guildId, ulong commandId)
{
    var httpClient = new HttpClient();
    var httpRequestMessage = new HttpRequestMessage()
    {
        Method = HttpMethod.Delete,
        RequestUri = new Uri($"https://discord.com/api/v6/applications/{applicationId}/guilds/{guildId}/commands/{commandId}")
    };
    httpRequestMessage.Headers.Add("Authorization", "Bot " + Environment.GetEnvironmentVariable("TOKEN"));
    var response = await httpClient.SendAsync(httpRequestMessage);
    Console.WriteLine(httpRequestMessage.ToString());
    Console.WriteLine(response.StatusCode);
}
#

if that is something for you :D