aboutsummaryrefslogtreecommitdiff
path: root/bot.js
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2020-07-19 12:59:04 -0400
committerAndrew Lee <alee14498@protonmail.com>2020-07-19 12:59:04 -0400
commit33c1efcc7b9914529af8c690e8757887365461cc (patch)
treefc4fe6da7aeef550a0eebfe5759c9472ed8e691f /bot.js
parentcacb78dfd848347d02fd257e244afb8950670476 (diff)
downloadDLAP-33c1efcc7b9914529af8c690e8757887365461cc.tar.gz
DLAP-33c1efcc7b9914529af8c690e8757887365461cc.tar.bz2
DLAP-33c1efcc7b9914529af8c690e8757887365461cc.zip
Added when bot is ready it will connect to vc
Diffstat (limited to 'bot.js')
-rw-r--r--bot.js21
1 files changed, 14 insertions, 7 deletions
diff --git a/bot.js b/bot.js
index 6fb8211..3d56dd3 100644
--- a/bot.js
+++ b/bot.js
@@ -3,14 +3,25 @@ const client = new Discord.Client();
const config = require('./token.json');
const fs = require('fs');
let prefix = "!";
+var voiceChannel = "734184921433899108";
function playAudio() {
-
+ console.log("Play Audio Function Activated.")
}
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
console.log('Prefix:', prefix);
+ const channel = client.channels.cache.get(voiceChannel);
+ if (!channel) return console.error("The channel does not exist!");
+ channel.join().then(connection => {
+ // Yay, it worked!
+ console.log("Successfully connected to this channel.");
+ playAudio()
+ }).catch(e => {
+ // Oh no, it errored! Let's log it to console :)
+ console.error(e);
+ });
});
client.on('message', async msg => {
@@ -34,15 +45,11 @@ client.on('message', async msg => {
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();
+ console.log("Connected to voice chat...")
+ const connection = await msg.member.voice.channel.join(734184921433899108);
playAudio();
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 == 'skip') {
//TODO