Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check if queue exists before doing other checks
- Loading branch information
1 parent
5d3b849
commit b488dce
Showing
11 changed files
with
50 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
const { canModifyQueue } = require("../util/EvobotUtil"); | ||
|
||
module.exports = { | ||
name: "volume", | ||
aliases: ['v'], | ||
aliases: ["v"], | ||
description: "Change volume of currently playing music", | ||
execute(message, args) { | ||
const serverQueue = message.client.queue.get(message.guild.id); | ||
const queue = message.client.queue.get(message.guild.id); | ||
|
||
if (!message.member.voice.channel) | ||
if (!queue) return message.reply("There is nothing playing.").catch(console.error); | ||
if (!canModifyQueue(message.member)) | ||
return message.reply("You need to join a voice channel first!").catch(console.error); | ||
if (!serverQueue) return message.reply("There is nothing playing.").catch(console.error); | ||
|
||
if (!args[0]) | ||
return message.reply(`🔊 The current volume is: **${serverQueue.volume}%**`).catch(console.error); | ||
if (!args[0]) return message.reply(`🔊 The current volume is: **${queue.volume}%**`).catch(console.error); | ||
if (isNaN(args[0])) return message.reply("Please use a number to set volume.").catch(console.error); | ||
if (parseInt(args[0]) > 100 || parseInt(args[0]) < 0) | ||
return message.reply("Please use a number between 0 - 100.").catch(console.error); | ||
|
||
serverQueue.volume = args[0]; | ||
serverQueue.connection.dispatcher.setVolumeLogarithmic(args[0] / 100); | ||
queue.volume = args[0]; | ||
queue.connection.dispatcher.setVolumeLogarithmic(args[0] / 100); | ||
|
||
return serverQueue.textChannel.send(`Volume set to: **${args[0]}%**`).catch(console.error); | ||
return queue.textChannel.send(`Volume set to: **${args[0]}%**`).catch(console.error); | ||
} | ||
}; |