diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2020-07-18 19:28:42 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2020-07-18 19:28:42 -0400 |
| commit | 9a1ac86aed3f7e488c70f2e321d2d056fae0838d (patch) | |
| tree | b8f9639c9a5d2665c5797269eca915248c4fe03c | |
| download | DLAP-9a1ac86aed3f7e488c70f2e321d2d056fae0838d.tar.gz DLAP-9a1ac86aed3f7e488c70f2e321d2d056fae0838d.tar.bz2 DLAP-9a1ac86aed3f7e488c70f2e321d2d056fae0838d.zip | |
Inital commit
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | bot.js | 46 | ||||
| -rw-r--r-- | package.json | 9 |
3 files changed, 58 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e1acb43 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +token.json +node_modules +yarn.lock
\ No newline at end of file @@ -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 diff --git a/package.json b/package.json new file mode 100644 index 0000000..1373a31 --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "name": "Project-Jul-2020-Discord-Bot", + "version": "1.0.0", + "main": "index.js", + "license": "MIT", + "dependencies": { + "discord.js": "^12.2.0" + } +} |
