Skip to content

Commit 7c23d4f

Browse files
committed
Add YouTube audio playback capabilities
Added YouTube audio playback capabilities for listening to music in voice channels.
1 parent c5c4fc6 commit 7c23d4f

File tree

1,534 files changed

+198114
-23
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,534 files changed

+198114
-23
lines changed

commands.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@
55
"/ratz slimedog",
66
"/ratz discorduserinfo + UserID",
77
"/ratz botinfo",
8-
"/ratz releaseinfo"
8+
"/ratz releaseinfo",
9+
"/ratz play + YouTube URL",
10+
"/ratz stop"
911
],
1012
"definitions": [
1113
"Shows all commands for ratzBot",
1214
"Shows user information for provided Steam64 ID",
1315
"Authorizes user to type in server chat after reading the rules",
1416
"Shows user information for provided numerical Discord ID (not discriminator)",
1517
"Shows all information about ratzBot",
16-
"Shows the latest release information of ratzBot"
18+
"Shows the latest release information of ratzBot",
19+
"Plays YouTube video audio",
20+
"Stops YouTube video audio"
1721
]
1822
}

main.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
// COPYRIGHT (C) GAVIN ISGAR 2017-2018
2+
13
const Discord = require("discord.js");
24
const DiscordRPC = require("discord-rpc");
5+
const opus = require("opusscript");
6+
const ffmpeg = require("ffmpeg-binaries");
7+
const ytdl = require("ytdl-core");
38
const bot = new Discord.Client();
49
const msg = new Discord.Message();
510
var net = require('net');
@@ -167,6 +172,43 @@ bot.on('message', (message) => {
167172
}
168173
})
169174
}
175+
// -----VOICE CHANNELS-----
176+
if (message.content.startsWith("/ratz play ")) {
177+
var result = message.content.slice(11);
178+
if (message.member.voiceChannel) {
179+
message.member.voiceChannel.join().then(connection => {
180+
try {
181+
const stream = ytdl(result, { filter: `audioonly` });
182+
const dispatcher = connection.playStream(stream);
183+
message.channel.send(`${message.author}, your music is now playing.`);
184+
dispatcher.on("end", end => {
185+
message.channel.send(`${message.author}, your music has ended.`);
186+
message.member.voiceChannel.leave();
187+
})
188+
}
189+
catch (err) {
190+
message.channel.send(`${message.author}, an error occured during the process. Try again later.`);
191+
}
192+
})
193+
}
194+
else {
195+
message.channel.send(`${message.author}, you are not in a voice channel. Join a voice channel to play music!`);
196+
}
197+
}
198+
if (message.content.toString() == "/ratz stop") {
199+
if (message.member.voiceChannel) {
200+
try {
201+
message.member.voiceChannel.connection.disconnect()
202+
message.member.voiceChannel.leave();
203+
}
204+
catch (err) {
205+
message.channel.send(`${message.author}, an error occured during the process. Try again later.`);
206+
}
207+
}
208+
else {
209+
message.channel.send(`${message.author}, you are not in a voice channel.`);
210+
}
211+
}
170212
// -----TOPIC DETECTION AND REVIEW-----
171213
if ((message.content.includes("XXXTentacion") || message.content.includes("xxxtentacion")) && (message.content.includes("death") || message.content.includes("died"))) {
172214
if (fs.readFileSync("./exclude/approvedmessages.ratz").includes(message.content.toString())) {

node_modules/.bin/lzmajs

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/lzmajs.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/seek-bunzip

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/seek-bunzip.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/seek-table

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/seek-table.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/base64-js/.travis.yml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/base64-js/LICENSE.MIT

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/base64-js/README.md

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/base64-js/bench/bench.js

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/base64-js/lib/b64.js

Lines changed: 124 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)