Init WIP Bot
This commit is contained in:
45
Client/discord-bot/utilities/registerCommands.js
Normal file
45
Client/discord-bot/utilities/registerCommands.js
Normal file
@@ -0,0 +1,45 @@
|
||||
import {SlashCommandBuilder} from "@discordjs/builders";
|
||||
import {REST} from "@discordjs/rest";
|
||||
import {getApplicationID, getGuildID, getTOKEN} from "./configHandler.js";
|
||||
import { Routes, ChannelType } from "discord.js";
|
||||
|
||||
const pingCommand = new SlashCommandBuilder()
|
||||
.setName("ping")
|
||||
.setDescription("Confirm the bot is online")
|
||||
.toJSON();
|
||||
|
||||
const joinCommand = new SlashCommandBuilder()
|
||||
.setName('join')
|
||||
.setDescription('Joins a voice channel')
|
||||
.addChannelOption((option) => option
|
||||
.setName('voicechannel')
|
||||
.setDescription('The Channel to voiceController')
|
||||
.setRequired(false)
|
||||
.addChannelTypes(ChannelType.GuildVoice))
|
||||
.toJSON();
|
||||
|
||||
const leaveCommand = new SlashCommandBuilder()
|
||||
.setName("leave")
|
||||
.setDescription("Leave current voice channel")
|
||||
.toJSON();
|
||||
|
||||
export default async function registerCommands(callback){
|
||||
const commands = [
|
||||
pingCommand,
|
||||
joinCommand,
|
||||
leaveCommand
|
||||
];
|
||||
|
||||
try {
|
||||
const rest = new REST({ version: '10' }).setToken(getTOKEN());
|
||||
const clientID = getApplicationID();
|
||||
const guildID = getGuildID();
|
||||
|
||||
await rest.put(Routes.applicationGuildCommands(clientID, guildID), {
|
||||
body: commands,
|
||||
});
|
||||
callback();
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user