69 lines
1.9 KiB
JavaScript
69 lines
1.9 KiB
JavaScript
//Config
|
|
import { getTOKEN, getGuildID, getApplicationID } from './utilities/configHandler.js';
|
|
// Commands
|
|
import ping from './controllers/ping.js';
|
|
import { join, leave } from './controllers/voiceController.js';
|
|
// Debug
|
|
import Debug from 'debug';
|
|
const debug = Debug("bot:app");
|
|
// Modules
|
|
import { Client, GatewayIntentBits } from 'discord.js';
|
|
// Utilities
|
|
import registerCommands from './utilities/registerCommands.js';
|
|
|
|
// Create the Discord client
|
|
const client = new Client({
|
|
intents: [
|
|
GatewayIntentBits.Guilds,
|
|
GatewayIntentBits.GuildMessages,
|
|
GatewayIntentBits.MessageContent,
|
|
GatewayIntentBits.GuildVoiceStates
|
|
]
|
|
});
|
|
|
|
// When the client is connected and ready
|
|
client.on('ready', () =>{
|
|
debug(`${client.user.tag} is ready`)
|
|
console.log(`${client.user.tag} is ready`)
|
|
});
|
|
|
|
/*
|
|
* Saved For later
|
|
client.on('messageCreate', (message) => {
|
|
debug(`Message Sent by: ${message.author.tag}\n\t'${message.content}'`);
|
|
console.log(`Message Sent by: ${message.author.tag}\n\t'${message.content}'`);
|
|
});
|
|
*/
|
|
|
|
// When a command is sent
|
|
client.on('interactionCreate', (interaction) => {
|
|
if (interaction.isChatInputCommand()){
|
|
switch (interaction.commandName) {
|
|
case "ping":
|
|
ping(interaction);
|
|
break;
|
|
case "join":
|
|
join(interaction);
|
|
break;
|
|
case "leave":
|
|
leave(interaction);
|
|
break;
|
|
default:
|
|
interaction.reply({ content: 'Command not found, try one that exists', fetchReply: true })
|
|
.then((message) => console.log(`Reply sent with content ${message.content}`))
|
|
.catch(console.error);
|
|
}
|
|
}
|
|
})
|
|
|
|
function loginBot(){
|
|
client.login(getTOKEN());
|
|
}
|
|
|
|
function main(){
|
|
registerCommands(() => {
|
|
loginBot();
|
|
});
|
|
}
|
|
|
|
main(); |