-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.js
More file actions
32 lines (29 loc) · 1.21 KB
/
deploy.js
File metadata and controls
32 lines (29 loc) · 1.21 KB
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
const { Routes } = require("discord.js");
const { REST } = require('@discordjs/rest');
const fs = require('fs');
module.exports = async (client) => {
client.commands = new Map();
let commands = [];
let files = fs.readdirSync(`./commands/`);
for (let file of files) {
const command = require(`./commands/${file}`);
if (command.func) {
let commandData = await command.data(client);
client.commands.set(commandData.name, command);
commands.push(commandData.toJSON());
} else {
client.commands.set(command.data.name, command);
commands.push(command.data.toJSON());
}
}
// commands
const rest = new REST({ version: '10' }).setToken(process.env.TOKEN);
try {
// make sure to replace GUILD ID HERE with the ID of your server
// you can find this by turning on developer mode in your settings, right clicking the server icon, and clicking "Copy ID"
await rest.put(Routes.applicationGuildCommands(client.user.id, process.env.GUILD_ID), { body: commands });
console.log(`Successfully registered ${commands.length} commands!`);
} catch (error) {
console.error(error);
}
}