135 lines
3.1 KiB
JavaScript
135 lines
3.1 KiB
JavaScript
import { REST, Routes } from "discord.js";
|
|
const { TOKEN, CLIENT_ID, GUILD_ID } = require("./config.json");
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
|
|
// set static commands
|
|
const commands = [
|
|
{
|
|
name: "hello",
|
|
description: "Replies 'world'",
|
|
},
|
|
{
|
|
name: "topicking",
|
|
description: "Pulls team and addup channel members into picking channel",
|
|
},
|
|
{
|
|
name: "end",
|
|
description: "Pulls team and addup channel members into picking channel",
|
|
},
|
|
{
|
|
name: "resetteams",
|
|
description: "Pulls team channel members into picking channel",
|
|
},
|
|
/*{
|
|
name: "testfk",
|
|
description: "debug fk",
|
|
},*/
|
|
{
|
|
name: "fklist",
|
|
description: "Pulls addup channel members into fk channel and lists them",
|
|
},
|
|
{
|
|
name: "listfk",
|
|
description: "Pulls addup channel members into fk channel and lists them",
|
|
},
|
|
{
|
|
name: "clear",
|
|
description: "Clears bot messages in command channel",
|
|
},
|
|
{
|
|
name: "bclear",
|
|
description: "Clears bot messages in command channel",
|
|
},
|
|
{
|
|
name: "scout",
|
|
description: "Lists picking channel members with scout role",
|
|
},
|
|
{
|
|
name: "soldier",
|
|
description: "Lists picking channel members with soldier role",
|
|
},
|
|
{
|
|
name: "pyro",
|
|
description: "Lists picking channel members with pyro role",
|
|
},
|
|
{
|
|
name: "demo",
|
|
description: "Lists picking channel members with demo role",
|
|
},
|
|
{
|
|
name: "demoman",
|
|
description: "Alias of /demo",
|
|
},
|
|
{
|
|
name: "heavy",
|
|
description: "Lists picking channel members with heavy role",
|
|
},
|
|
{
|
|
name: "engineer",
|
|
description: "Lists picking channel members with engineer role",
|
|
},
|
|
{
|
|
name: "engi",
|
|
description: "Alias of /engineer",
|
|
},
|
|
{
|
|
name: "medic",
|
|
description: "Lists picking channel members with medic role",
|
|
},
|
|
{
|
|
name: "sniper",
|
|
description: "Lists picking channel members with sniper role",
|
|
},
|
|
{
|
|
name: "spy",
|
|
description: "Lists picking channel members with spy role",
|
|
},
|
|
{
|
|
name: "pick",
|
|
description: "Automatically picks teams",
|
|
},
|
|
{
|
|
name: "autocaptain",
|
|
description: "Automatically picks teams",
|
|
},
|
|
];
|
|
|
|
// get commands from files
|
|
const commandsPath = path.join(__dirname, "commands");
|
|
const commandFiles = fs.readdirSync(commandsPath);
|
|
|
|
for (const file of commandFiles) {
|
|
const command = require(`./commands/${file}`);
|
|
if ("data" in command && "execute" in command) {
|
|
commands.push(command.data.toJSON());
|
|
} else {
|
|
console.error(`${__filename}: Invalid command file: ${file}`);
|
|
}
|
|
}
|
|
|
|
const rest = new REST({ version: "10" }).setToken(TOKEN);
|
|
|
|
try {
|
|
console.log("Started refreshing application (/) commands.");
|
|
|
|
// application reload
|
|
await rest.put(Routes.applicationCommands(CLIENT_ID), {
|
|
body: commands,
|
|
});
|
|
|
|
// guild reload, faster than application reload
|
|
//await rest.put(Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID), {
|
|
// body: commands,
|
|
//});
|
|
|
|
// clear guild commands
|
|
//await rest.put(Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID), {
|
|
// body: [],
|
|
//});
|
|
|
|
console.log("Successfully reloaded application (/) commands.");
|
|
} catch (error) {
|
|
console.error(error);
|
|
}
|