deploy_commands.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import {REST} from '@discordjs/rest';
  2. import {Routes} from 'discord-api-types/v9';
  3. import Config from './config.js';
  4. const rest = new REST({version: '9'}).setToken(Config.discord_token);
  5. deploy_commands();
  6. // Docs: https://discord.com/developers/docs/interactions/application-commands
  7. async function deploy_commands() {
  8. const commands = [
  9. {
  10. type: 2,
  11. name: 'Display o!RL profile',
  12. description: '',
  13. options: [],
  14. default_permission: false,
  15. },
  16. {
  17. name: 'profile',
  18. description: 'Display your o!RL profile',
  19. options: [
  20. {
  21. type: 6,
  22. name: 'user',
  23. description: 'The user whose profile you want to get',
  24. required: false,
  25. },
  26. ],
  27. default_permission: false,
  28. },
  29. {
  30. name: 'eval',
  31. description: 'Run code on the bot',
  32. options: [
  33. {
  34. type: 3,
  35. name: 'code',
  36. description: 'The code to run',
  37. required: true,
  38. },
  39. ],
  40. default_permission: false,
  41. },
  42. ];
  43. // Create/Update guild commands
  44. await rest.put(
  45. Routes.applicationGuildCommands(Config.discord_bot_id, Config.discord_guild_id),
  46. {body: commands},
  47. );
  48. console.log('Successfully registered application commands.');
  49. }