Af girafpingvin (Daniel Bahl) for 2 år siden. Skrevet i JavaScript.
Embed
  1. const fs = require('node:fs');
  2. const path = require('node:path');
  3. const { REST } = require('@discordjs/rest');
  4. const { Routes } = require('discord.js');
  5.  
  6. const clientId = '1094912554930814976'; // Dit Client ID
  7. const guildId = '1075395077465178252'; // Dit Discord-server ID
  8.  
  9. const commands = [];
  10. const commandsPath = path.join(__dirname, 'kommandoer');
  11. const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
  12.  
  13.  
  14. for (const file of commandFiles) {
  15.     const filePath = path.join(commandsPath, file);
  16.     const command = require(filePath);
  17.     commands.push(command.data.toJSON());
  18. }
  19.  
  20. const rest = new REST({ version: '10' }).setToken('MTA......a0FkL-DJ5c'); // Din meget hemmelige token :)
  21.  
  22. rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
  23.     .then(() => console.log('Successfully registered application commands.'))
  24.     .catch(console.error);

Redigerede udgaver Deploy Commands til discord rss

Titel Navn Sprog Hvornår
Re: Deploy Commands til discord dsadsa javascript 2 år siden.