#HttpException when creating commands

1 messages · Page 1 of 1 (latest)

wide scarab
#

Here's part of my GenerateCommands function:

            foreach(CommandData command in Commands)
            {
                try {
                    commands[command.Name] = command;
                    SlashCommandBuilder builder = new();

                    builder.WithName(command.Name);
                    builder.WithDescription(command.Description);
                    command.Command = await client.CreateGlobalApplicationCommandAsync(builder.Build());
                } catch (HttpException ex)
                {
                    var logger = Logger.Instance;
                    logger.Log($"HttpException in CommandCreator.GenerateCommands: {ex} (Caught)", LogLevel.ERROR);
                    logger.Log($"HttpException.DiscordCode is {ex.DiscordCode}", LogLevel.ERROR);
                    logger.Log($"HttpException.Errors is {ex.Errors}", LogLevel.ERROR);
                    logger.Log($"HttpException.HttpCode is {ex.HttpCode}", LogLevel.ERROR);
                    logger.Log($"HttpException.Reason is {ex.Reason}", LogLevel.ERROR);
                } catch (Exception ex)
            }

            return commands;
        }

Here's the output:

[3/3/2024 1:19:52 PM - ERROR] HttpException in CommandCreator.GenerateCommands: Discord.Net.HttpException: The server responded with error 405: 405: Method Not Allowed
   at ... (i ran out of chars)
[3/3/2024 1:19:52 PM - ERROR] HttpException.DiscordCode is GeneralError
[3/3/2024 1:19:52 PM - ERROR] HttpException.Errors is System.Collections.Immutable.ImmutableArray`1[Discord.DiscordJsonError]
[3/3/2024 1:19:52 PM - ERROR] HttpException.HttpCode is MethodNotAllowed
[3/3/2024 1:19:52 PM - ERROR] HttpException.Reason is 405: Method Not Allowed

I'm pretty confused about this. I can show more code (Program.cs and my example command) if needed

wide scarab
#

I forgot to mention, CommandData has the name description and action to be performed on the commands trigger

#

Never mind, I just needed to wait for client.Ready

#

I’m pretty dim lmao