()
| 25 | }); |
| 26 | |
| 27 | async function createCommand() { |
| 28 | const appId = process.env.APP_ID; |
| 29 | |
| 30 | /** |
| 31 | * Globally-scoped slash commands (generally only recommended for production) |
| 32 | * See https://discord.com/developers/docs/interactions/application-commands#create-global-application-command |
| 33 | */ |
| 34 | const globalEndpoint = `applications/${appId}/commands`; |
| 35 | |
| 36 | /** |
| 37 | * Guild-scoped slash commands |
| 38 | * See https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command |
| 39 | */ |
| 40 | // const guildEndpoint = `applications/${appId}/guilds/<your guild id>/commands`; |
| 41 | const commandBody = { |
| 42 | name: 'test', |
| 43 | description: 'Just your average command', |
| 44 | // chat command (see https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types) |
| 45 | type: 1, |
| 46 | }; |
| 47 | |
| 48 | try { |
| 49 | // Send HTTP request with bot token |
| 50 | const res = await DiscordRequest(globalEndpoint, { |
| 51 | method: 'POST', |
| 52 | body: commandBody, |
| 53 | }); |
| 54 | console.log(await res.json()); |
| 55 | } catch (err) { |
| 56 | console.error('Error installing commands: ', err); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | app.listen(3000, () => { |
| 61 | console.log('Listening on port 3000'); |
no test coverage detected