27 lines
890 B
JavaScript
27 lines
890 B
JavaScript
|
const fs = require("node:fs");
|
||
|
const { REST } = require("@discordjs/rest");
|
||
|
const { Routes } = require("discord-api-types/v9");
|
||
|
const { token } = require('./config.json');
|
||
|
const { exec } = require('child_process');
|
||
|
|
||
|
const rest = new REST({ version: "9" }).setToken(token);
|
||
|
|
||
|
console.log('building...');
|
||
|
exec('pnpm tsc', (err, stdout, stderr) => {
|
||
|
if (err) throw err;
|
||
|
|
||
|
console.log(stdout);
|
||
|
|
||
|
const commands = [];
|
||
|
const commandFiles = fs.readdirSync("./built/commands").filter((file) => file.endsWith(".js") && !file.startsWith('.'));
|
||
|
|
||
|
for (const file of commandFiles) {
|
||
|
const command = require(`./built/commands/${file}`);
|
||
|
commands.push(command.data.toJSON());
|
||
|
}
|
||
|
|
||
|
rest
|
||
|
.put(Routes.applicationGuildCommands('898850107892596776', '587108210121506816'), { body: commands })
|
||
|
.then(() => console.log(`${commands.length} commands added`))
|
||
|
.catch(console.error);
|
||
|
});
|