Init WIP Bot

This commit is contained in:
Logan Cusano
2022-12-11 06:09:25 -05:00
parent f1f4cb7750
commit 4e1b82c557
43 changed files with 6766 additions and 0 deletions

69
Client/discord-bot/app.js Normal file
View File

@@ -0,0 +1,69 @@
//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();