From fbc5991bf80c765defeba30976a009ea6972ae72 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Fri, 12 Feb 2021 18:19:04 -0500 Subject: [PATCH] Add pause and resume --- commands/util-voice/pause.js | 28 ++++++++++++++++++++++++++++ commands/util-voice/resume.js | 28 ++++++++++++++++++++++++++++ commands/util-voice/stop.js | 2 +- 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 commands/util-voice/pause.js create mode 100644 commands/util-voice/resume.js diff --git a/commands/util-voice/pause.js b/commands/util-voice/pause.js new file mode 100644 index 00000000..55b6d555 --- /dev/null +++ b/commands/util-voice/pause.js @@ -0,0 +1,28 @@ +const Command = require('../../structures/Command'); + +module.exports = class PauseCommand extends Command { + constructor(client) { + super(client, { + name: 'pause', + aliases: ['pause-voice-channel', 'pause-vc', 'pause-voice', 'pause-music', 'pause-playing'], + group: 'util-voice', + memberName: 'pause', + description: 'Pauses the current audio playing.', + guildOnly: true, + guarded: true + }); + } + + run(msg) { + const connection = this.client.voice.connections.get(msg.guild.id); + if (!connection) return msg.reply('I am not in a voice channel.'); + if (!msg.channel.permissionsFor(msg.author).has('MOVE_MEMBERS') && connection.channel.members.size > 2) { + return msg.reply('You need the "Move members" permission to stop playing audio.'); + } + if (!this.client.dispatchers.has(msg.guild.id)) { + return msg.reply(`I am not currently playing audio in this server.`); + } + this.client.dispatchers.get(msg.guild.id).pause(); + return msg.reply('Paused playing.'); + } +}; diff --git a/commands/util-voice/resume.js b/commands/util-voice/resume.js new file mode 100644 index 00000000..1d505291 --- /dev/null +++ b/commands/util-voice/resume.js @@ -0,0 +1,28 @@ +const Command = require('../../structures/Command'); + +module.exports = class ResumeCommand extends Command { + constructor(client) { + super(client, { + name: 'resume', + aliases: ['resume-voice-channel', 'resume-vc', 'resume-voice', 'resume-music', 'resume-playing'], + group: 'util-voice', + memberName: 'resume', + description: 'Resume the current audio playing.', + guildOnly: true, + guarded: true + }); + } + + run(msg) { + const connection = this.client.voice.connections.get(msg.guild.id); + if (!connection) return msg.reply('I am not in a voice channel.'); + if (!msg.channel.permissionsFor(msg.author).has('MOVE_MEMBERS') && connection.channel.members.size > 2) { + return msg.reply('You need the "Move members" permission to stop playing audio.'); + } + if (!this.client.dispatchers.has(msg.guild.id)) { + return msg.reply(`I am not currently playing audio in this server.`); + } + this.client.dispatchers.get(msg.guild.id).resume(); + return msg.reply('Resumed playing.'); + } +}; diff --git a/commands/util-voice/stop.js b/commands/util-voice/stop.js index bb6a3410..044c5182 100644 --- a/commands/util-voice/stop.js +++ b/commands/util-voice/stop.js @@ -4,7 +4,7 @@ module.exports = class StopCommand extends Command { constructor(client) { super(client, { name: 'stop', - aliases: ['stop-voice-channel', 'stop-vc', 'stop-voice', 'stop-play', 'stop-playing'], + aliases: ['stop-voice-channel', 'stop-vc', 'stop-voice', 'stop-music', 'stop-playing'], group: 'util-voice', memberName: 'stop', description: 'Stops the current audio playing.',