const { REST, SlashCommandBuilder, Routes } = require('discord.js');
const { Client, GatewayIntentBits } = require('discord.js');
const { clientId, guildId, token } = require('./token.json');
const commands = [
new SlashCommandBuilder().setName('ping').setDescription('Replies with pong!'),
new SlashCommandBuilder().setName('server').setDescription('Replies with server info!'),
new SlashCommandBuilder().setName('user').setDescription('Replies with user info!'),
// 設定指令名稱與敘述
]
const rest = new REST({ version: '10' }).setToken(token);
//設定要獲取資料
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
.then((data) => console.log(`Successfully registered ${data.length} application commands.`))
.catch(console.error);
//設定這個command是哪隻機器人與哪個伺服器
//成功的話就會告知成功新增幾筆指令
這樣就完成指令的設定與獲取伺服器的資料了。