From 2163cd881373cbef83375a5b9d2ed55e8c95465c Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sat, 18 Jul 2020 20:45:06 -0400 Subject: Logging stuff and playing from an audio file --- bot.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'bot.js') diff --git a/bot.js b/bot.js index 64aa651..82f4444 100644 --- a/bot.js +++ b/bot.js @@ -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!'); -- cgit v1.2.3