Edits history of script submission #398 for ' Add a command to a Discord bot (discord)'

  • deno
    import { SlashCommandBuilder } from "npm:@discordjs/[email protected]";
    
    export async function main(
      applicationId: string,
      botToken: string,
      commandName: string = "windmill-help",
      commandDescription: string = "Ask a question about Windmill",
      optionDescription: string = "Ask a question about Windmill"
    ) {
      const command = new SlashCommandBuilder()
        .setName(commandName)
        .setDescription(commandDescription)
        .addStringOption((option) =>
          option.setName("question").setDescription(optionDescription)
        );
    
      const url = `https://discord.com/api/v10/applications/${applicationId}/commands`;
    
      await fetch(url, {
        method: "POST",
        headers: {
          Authorization: `Bot ${botToken}`,
          "Content-Type": "application/json",
        },
        body: JSON.stringify(command.toJSON()),
      });
    }
    

    Submitted by henri186 1055 days ago