From cb973d333b1d16c10b91bcaf703f661ccbf3e7a1 Mon Sep 17 00:00:00 2001 From: Hazem Krimi Date: Fri, 8 May 2020 15:53:42 +0100 Subject: [PATCH] added volume and earrape commands --- commands/music/earrape.js | 41 +++++++++++++++++++++++++++++++++ commands/music/volume.js | 48 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 commands/music/earrape.js create mode 100644 commands/music/volume.js diff --git a/commands/music/earrape.js b/commands/music/earrape.js new file mode 100644 index 0000000..9203f25 --- /dev/null +++ b/commands/music/earrape.js @@ -0,0 +1,41 @@ +const { Command } = require('discord.js-commando'); +const { MessageEmbed } = require('discord.js'); + +module.exports = class Play extends Command { + constructor(client) { + super(client, { + name: 'earrape', + memberName: 'earrape', + group: 'music', + description: 'toggles the earrape sfx', + 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 { + message.guild.music.dispatcher.setVolume(message.guild.music.sfx.earrape ? 1 : 10000); + message.guild.music.sfx.earrape = !message.guild.music.sfx.earrape; + const embed = new MessageEmbed().setColor('#000099').setTitle(`:loud_sound: Earrape ${message.guild.music.sfx.earrape ? 'on' : 'off'}`); + 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 }); + } + } +} \ No newline at end of file diff --git a/commands/music/volume.js b/commands/music/volume.js new file mode 100644 index 0000000..d72d049 --- /dev/null +++ b/commands/music/volume.js @@ -0,0 +1,48 @@ +const { Command } = require('discord.js-commando'); +const { MessageEmbed } = require('discord.js'); + +module.exports = class Play extends Command { + constructor(client) { + super(client, { + name: 'volume', + memberName: 'volume', + group: 'music', + description: 'sets the volume of the player', + guildOnly: true, + throttling: { + usages: 1, + duration: 5 + }, + args: [ + { + key: 'query', + prompt: 'specify the volume (greater than 0)', + type: 'string', + validate: query => query.length > 0 && parseInt(query) > 0 + } + ], + }); + } + + run = async (message, { query }) => { + 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 { + message.guild.music.dispatcher.setVolume(parseInt(query) / 100); + const embed = new MessageEmbed().setColor('#000099').setTitle(`:sound: Volume set to ${query}%`); + 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 }); + } + } +} \ No newline at end of file