-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.js
More file actions
38 lines (29 loc) · 1.1 KB
/
deploy.js
File metadata and controls
38 lines (29 loc) · 1.1 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
33
34
35
36
37
"use strict";
require("dotenv").config();
const util = require("util");
const exec = util.promisify(require('child_process').exec);
const fs = require("fs");
const path = require("path");
const { REST, Routes } = require("discord.js");
const token = process.env.TOKEN;
const appId = process.env.APP_ID;
const rest = new REST({ version: "10" }).setToken(token);
const commandPath = path.join(__dirname, "commands");
const commandFiles = fs.readdirSync(commandPath).filter( file => file.endsWith(".js"));
const commands = [];
for (const file of commandFiles) {
const filePath = path.join(commandPath, file);
const command = require(filePath);
commands.push(command.data.toJSON());
}
(async () => {
try {
//await exec("mkdir db");
//await exec("touch ./db/db.sqlite");
console.log(`[INFO] STARTED LOADING ${commands.length} (/) COMMANDS`);
const data = await rest.put(Routes.applicationCommands(appId), { body: commands });
console.log(`[INFO] SUCCESFUL LOADED ${data.length} (/) commands`);
} catch(e) {
console.error(`[ERROR] ${e}`);
}
})();