如何改变音乐的音量?不和谐的js

时间:2020-09-02 01:23:08

标签: javascript discord bots

我正在处理音乐命令。如何做到这一点,以便使用我的机器人的用户可以自定义音量。像!volume 3一样,音乐音量也会降低。请帮忙。我的默认音量为5

我的代码:

bot.on("message", async message => {
    if (message.author.bot) return;
    if (!message.content.startsWith(PREFIX)) return;
    if (message.channel.type === 'dm') return;

    const serverQueue = queue.get(message.guild.id);

    if (message.content.startsWith(`${PREFIX}plays`)) {
        message.channel.send('Searching for your song...')
        execute(message, serverQueue).catch((_err) => {
            message.channel.send('I was not able to fulfill your request')
        })
        return;
    } else if (message.content.startsWith(`${PREFIX}skips`)) {
        skip(message, serverQueue);
        return;
    } else if (message.content.startsWith(`${PREFIX}stops`)) {
        if(!serverQueue) return message.channel.send('There is nothing playing')
        stop(message, serverQueue)
        return;

1 个答案:

答案 0 :(得分:0)

我猜您将VoiceConnection存储在serverQueue中了吗? 如果这样做,则可以从VoiceConnection中获得serverQueue,并通过StreamDispatcher获得VoiceConnection.dispatcher。然后使用方法StreamDispatcher#setVolume更改音乐的音量。