const { Command } = require('discord.js-commando'); const emoji = require('emoji-random'); module.exports = class VolumeVoice extends Command { constructor(client) { super(client, { name: 'volume', aliases: ['vol', 'v'], group: 'voice', memberName: 'volume', description: 'Changes the volume of playback.', guildOnly: true, args: [ { key: 'wantedVol', prompt: 'What would you like the volume to be? (1 - 200)', type: 'integer', validate: wantedVol => wantedVol >= 1 && wantedVol <= 200 } ], examples: [ 'msb!volume 20', 'msb!vol 50', 'msb!v 70' ] }); } run(msg, { wantedVol }) { var voiceChannel = msg.member.voice.channel; if (!voiceChannel) return msg.reply('Join a channel and try again. ' + emoji.random()); if ( typeof msg.guild.musicData.songDispatcher == 'undefined' || msg.guild.musicData.songDispatcher == null ) { return msg.reply('The soundtrack isn\'t playing right now. ' + emoji.random()); } const volume = wantedVol / 100; msg.guild.musicData.volume = volume; msg.guild.musicData.songDispatcher.setVolume(volume); msg.reply(`Volume is now: **${wantedVol}%** ` + emoji.random()); } };