Skip to content

Commit

Permalink
refactor: refactor increase/decrease volume reaction
Browse files Browse the repository at this point in the history
  • Loading branch information
eritislami committed Nov 6, 2020
1 parent 2a0007b commit c235df8
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions include/play.js
Expand Up @@ -14,6 +14,7 @@ module.exports = {
PRUNING = process.env.PRUNING;
SOUNDCLOUD_CLIENT_ID = process.env.SOUNDCLOUD_CLIENT_ID;
}

const queue = message.client.queue.get(message.guild.id);

if (!song) {
Expand All @@ -30,17 +31,9 @@ module.exports = {
stream = await ytdlDiscord(song.url, { highWaterMark: 1 << 25 });
} else if (song.url.includes("soundcloud.com")) {
try {
stream = await scdl.downloadFormat(
song.url,
scdl.FORMATS.OPUS,
SOUNDCLOUD_CLIENT_ID ? SOUNDCLOUD_CLIENT_ID : undefined
);
stream = await scdl.downloadFormat(song.url, scdl.FORMATS.OPUS, SOUNDCLOUD_CLIENT_ID);
} catch (error) {
stream = await scdl.downloadFormat(
song.url,
scdl.FORMATS.MP3,
SOUNDCLOUD_CLIENT_ID ? SOUNDCLOUD_CLIENT_ID : undefined
);
stream = await scdl.downloadFormat(song.url, scdl.FORMATS.MP3, SOUNDCLOUD_CLIENT_ID);
streamType = "unknown";
}
}
Expand Down Expand Up @@ -142,7 +135,7 @@ module.exports = {

case "馃攭":
reaction.users.remove(user).catch(console.error);
if (!canModifyQueue(member)) return;
if (!canModifyQueue(member) || queue.volume == 0) return;
if (queue.volume - 10 <= 0) queue.volume = 0;
else queue.volume = queue.volume - 10;
queue.connection.dispatcher.setVolumeLogarithmic(queue.volume / 100);
Expand All @@ -153,7 +146,7 @@ module.exports = {

case "馃攰":
reaction.users.remove(user).catch(console.error);
if (!canModifyQueue(member)) return;
if (!canModifyQueue(member) || queue.volume == 100) return;
if (queue.volume + 10 >= 100) queue.volume = 100;
else queue.volume = queue.volume + 10;
queue.connection.dispatcher.setVolumeLogarithmic(queue.volume / 100);
Expand Down

0 comments on commit c235df8

Please sign in to comment.