69 lines
1.8 KiB
JavaScript
69 lines
1.8 KiB
JavaScript
//Config
|
|
import { getTOKEN, getGuildID, getApplicationID } from './utilities/configHandler.js';
|
|
// Commands
|
|
import ping from './commands/ping.js';
|
|
import join from './commands/join.js';
|
|
import leave from './commands/leave.js';
|
|
// Debug
|
|
import ModuleDebugBuilder from "./utilities/moduleDebugBuilder.js";
|
|
const log = new ModuleDebugBuilder("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', () =>{
|
|
log.INFO(`${client.user.tag} is ready`)
|
|
});
|
|
|
|
/*
|
|
* Saved For later
|
|
client.on('messageCreate', (message) => {
|
|
log.DEBUG(`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) => log.DEBUG(`Reply sent with content ${message.content}`))
|
|
.catch((err) => log.ERROR(err));
|
|
}
|
|
}
|
|
})
|
|
|
|
function loginBot(){
|
|
client.login(getTOKEN());
|
|
}
|
|
|
|
function main(){
|
|
registerCommands(() => {
|
|
loginBot();
|
|
});
|
|
}
|
|
|
|
main();
|
|
//module.exports = client;
|