-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-commands.js
41 lines (31 loc) · 1.14 KB
/
deploy-commands.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const { REST } = require('@discordjs/rest');
const { Client, Collection, Intents } = require('discord.js');
const { Routes } = require('discord-api-types/v9');
const { clientId, guildID, token } = require('./config.json');
const { getAllFiles } = require('./helpers.js')
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
const commands = [];
const rest = new REST({ version: '9' }).setToken(token);
const commandFiles = getAllFiles('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`${file}`);
commands.push(command);
}
async function main(){
await client.login(token);
console.log(commands);
try{
for(cmd of commands){
const cmdResult = await client.guilds.cache.get('367198129633886209')?.commands.create(cmd);
console.log(cmdResult);
}
console.log("Successfully deployed commands");
}
catch(err) {
console.error(err.message);
}
}
main();
// rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
// .then(() => console.log('Successfully registered application commands.'))
// .catch(console.error);