summaryrefslogtreecommitdiff
path: root/src/commands/voice/volume.js
blob: bd5f0b064d70e7455a4e1532553e3df25a2a1231 (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
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());
    }
};