mirror of
https://github.com/hazemKrimi/discord-bot.git
synced 2026-05-01 18:30:25 +00:00
added pause, resume and skip commands
This commit is contained in:
@@ -0,0 +1,45 @@
|
|||||||
|
const { Command } = require('discord.js-commando');
|
||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
|
module.exports = class Play extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'pause',
|
||||||
|
memberName: 'pause',
|
||||||
|
group: 'music',
|
||||||
|
description: 'pauses the player',
|
||||||
|
guildOnly: true,
|
||||||
|
throttling: {
|
||||||
|
usages: 1,
|
||||||
|
duration: 5
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
run = async message => {
|
||||||
|
try {
|
||||||
|
if (!message.member.voice.channel) {
|
||||||
|
const embed = new MessageEmbed().setColor('#ff0000').setTitle(':x: You need to join a voice channel first');
|
||||||
|
return await message.say({ embed });
|
||||||
|
}
|
||||||
|
else if (!message.guild.music.isPlaying) {
|
||||||
|
const embed = new MessageEmbed().setColor('#ff0000').setTitle(':x: Play something first');
|
||||||
|
return message.say({ embed });
|
||||||
|
}
|
||||||
|
else if (message.guild.music.paused) {
|
||||||
|
const embed = new MessageEmbed().setColor('#ff0000').setTitle(':x: Already paused');
|
||||||
|
return message.say({ embed });
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
message.guild.music.paused = true;
|
||||||
|
message.guild.music.dispatcher.pause(true);
|
||||||
|
const embed = new MessageEmbed().setColor('#000099').setTitle(':pause_button: paused player');
|
||||||
|
return await message.say({ embed });
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
const embed = new MessageEmbed().setColor('#ff0000').setTitle(':x: Error occured, if you are my creator please fix me soon');
|
||||||
|
return message.say({ embed });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
const { Command } = require('discord.js-commando');
|
||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
|
module.exports = class Play extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'resume',
|
||||||
|
memberName: 'resume',
|
||||||
|
group: 'music',
|
||||||
|
description: 'resumes the player',
|
||||||
|
guildOnly: true,
|
||||||
|
throttling: {
|
||||||
|
usages: 1,
|
||||||
|
duration: 5
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
run = async message => {
|
||||||
|
try {
|
||||||
|
if (!message.member.voice.channel) return message.reply('you need to join a channel!');
|
||||||
|
else if (!message.guild.music.isPlaying) {
|
||||||
|
const embed = new MessageEmbed().setColor('#ff0000').setTitle(':x: Play something first');
|
||||||
|
return message.say({ embed });
|
||||||
|
}
|
||||||
|
else if (!message.guild.music.paused) {
|
||||||
|
const embed = new MessageEmbed().setColor('#ff0000').setTitle(':x: Playing already');
|
||||||
|
return message.say({ embed });
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
message.guild.music.paused = false;
|
||||||
|
message.guild.music.dispatcher.resume();
|
||||||
|
const embed = new MessageEmbed().setColor('#000099').setTitle(':arrow_forward: resumed player');
|
||||||
|
return await message.say({ embed });
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
const embed = new MessageEmbed().setColor('#ff0000').setTitle(':x: Error occured, if you are my creator please fix me soon');
|
||||||
|
return message.say({ embed });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
const { Command } = require('discord.js-commando');
|
||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
|
module.exports = class Play extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'skip',
|
||||||
|
memberName: 'skip',
|
||||||
|
group: 'music',
|
||||||
|
description: 'skips the current track',
|
||||||
|
guildOnly: true,
|
||||||
|
throttling: {
|
||||||
|
usages: 1,
|
||||||
|
duration: 5
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
run = async message => {
|
||||||
|
try {
|
||||||
|
if (!message.member.voice.channel) {
|
||||||
|
const embed = new MessageEmbed().setColor('#ff0000').setTitle(':x: You need to join a voice channel first');
|
||||||
|
return await message.say({ embed });
|
||||||
|
}
|
||||||
|
else if (!message.guild.music.isPlaying) {
|
||||||
|
const embed = new MessageEmbed().setColor('#ff0000').setTitle(':x: Play something first');
|
||||||
|
return await message.say({ embed });
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
message.guild.music.dispatcher.emit('finish');
|
||||||
|
const embed = new MessageEmbed().setColor('#000099').setTitle(':stop_button: Skipped current track');
|
||||||
|
return await message.say({ embed });
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
const embed = new MessageEmbed().setColor('#ff0000').setTitle(':x: Error occured, if you are my creator please fix me soon');
|
||||||
|
return message.say({ embed });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user