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'], group: 'voice', memberName: 'volume', description: 'changes volume of audio if playing', guildOnly: true, args: [ { key: 'wantedVol', prompt: 'what volume u want, from 1 to 200', type: 'integer', validate: wantedVol => wantedVol >= 1 && wantedVol <= 200 } ], examples: [ 's5n!volume 20', 's5n!vol 50' ] }); } 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('there isn\'t a song playing right now lol ' + 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()); } };