summaryrefslogtreecommitdiff
path: root/src/commands/voice/volume.js
blob: 96a6de33d591bb13c360b58255d22de005fe162f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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 any currentaly playing audio.',
            guildOnly: true,
            args: [
                {
                    key: 'wantedVol',
                    prompt: 'What would volume you like? (1 to 200)',
                    type: 'integer',
                    validate: wantedVol => wantedVol >= 1 && wantedVol <= 200
                }
            ],
            examples: [
                'uwu!volume 20',
                'uwu!vol 50'
            ],
            clientPermissions: ['SPEAK', 'CONNECT', 'SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
            userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY'],
        });
    }
    run(msg, { wantedVol }) {
        var voiceChannel = msg.member.voice.channel;
        if (!voiceChannel) return msg.reply('Please 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 any audio 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());
    }
};