From 9a1ac86aed3f7e488c70f2e321d2d056fae0838d Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sat, 18 Jul 2020 19:28:42 -0400 Subject: Inital commit --- bot.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 bot.js (limited to 'bot.js') diff --git a/bot.js b/bot.js new file mode 100644 index 0000000..64aa651 --- /dev/null +++ b/bot.js @@ -0,0 +1,46 @@ +const Discord = require('discord.js'); +const client = new Discord.Client(); +const config = require('./token.json'); +let prefix = "!" + +client.on('ready', () => { + console.log(`Logged in as ${client.user.tag}!`); + console.log('Prefix:', prefix) +}); + +client.on('message', async msg => { + if (!['242775871059001344'].includes(msg.author.id)) return; + if (!msg.guild) return; + if (msg.author.bot) return; + if (!msg.content.startsWith(prefix)) return; + + let command = msg.content.split(" ")[0]; + command = command.slice(prefix.length); + + if (command == 'ping') { + msg.reply('Pong!'); + } + if (command == 'poweroff') { + console.log("Powering off..."); + client.destroy(); + process.exit(0); + } + if (command === 'join') { + // Only try to join the sender's voice channel if they are in one themselves + if (msg.member.voice.channel) { + const connection = await msg.member.voice.channel.join(); + } else { + msg.reply('You need to join a voice channel first!'); + } + } + if (command === 'leave') { + // Only try to join the sender's voice channel if they are in one themselves + if (msg.member.voice.channel) { + const connection = await msg.member.voice.channel.leave(); + } else { + msg.reply('You need to join a voice channel first!'); + } + } +}); + +client.login(config.token); \ No newline at end of file -- cgit v1.2.3