diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2020-07-18 20:45:06 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2020-07-18 20:45:06 -0400 |
| commit | 2163cd881373cbef83375a5b9d2ed55e8c95465c (patch) | |
| tree | c853bc16d61a07c1088bb68aab8bc477a3052844 | |
| parent | 9a1ac86aed3f7e488c70f2e321d2d056fae0838d (diff) | |
| download | DLAP-2163cd881373cbef83375a5b9d2ed55e8c95465c.tar.gz DLAP-2163cd881373cbef83375a5b9d2ed55e8c95465c.tar.bz2 DLAP-2163cd881373cbef83375a5b9d2ed55e8c95465c.zip | |
Logging stuff and playing from an audio file
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | bot.js | 20 | ||||
| -rw-r--r-- | package.json | 4 |
3 files changed, 21 insertions, 6 deletions
@@ -1,3 +1,4 @@ token.json node_modules -yarn.lock
\ No newline at end of file +yarn.lock +music
\ No newline at end of file @@ -1,11 +1,16 @@ const Discord = require('discord.js'); const client = new Discord.Client(); const config = require('./token.json'); +const fs = require('fs'); let prefix = "!" +function fetchAudio() { + +} + client.on('ready', () => { console.log(`Logged in as ${client.user.tag}!`); - console.log('Prefix:', prefix) + console.log('Prefix:', prefix); }); client.on('message', async msg => { @@ -18,24 +23,31 @@ client.on('message', async msg => { command = command.slice(prefix.length); if (command == 'ping') { - msg.reply('Pong!'); + msg.reply('Pong! ' + Math.round(client.ping) + ' ms'); } + if (command == 'poweroff') { console.log("Powering off..."); client.destroy(); process.exit(0); } - if (command === 'join') { + + if (command == 'join') { // Only try to join the sender's voice channel if they are in one themselves if (msg.member.voice.channel) { + console.log("Connected to voice chat...") const connection = await msg.member.voice.channel.join(); + connection.play('./music/4616-werq-by-kevin-macleod.mp3'); + console.log(connection) } else { msg.reply('You need to join a voice channel first!'); } } - if (command === 'leave') { + + if (command == 'leave') { // Only try to join the sender's voice channel if they are in one themselves if (msg.member.voice.channel) { + console.log("Disconnected from voice chat...") const connection = await msg.member.voice.channel.leave(); } else { msg.reply('You need to join a voice channel first!'); diff --git a/package.json b/package.json index 1373a31..39c223d 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,8 @@ "main": "index.js", "license": "MIT", "dependencies": { - "discord.js": "^12.2.0" + "@discordjs/opus": "^0.3.2", + "discord.js": "^12.2.0", + "ffmpeg-static": "^4.2.5" } } |
