diff --git a/bot.js b/bot.js index c4957ce..ad6933f 100644 --- a/bot.js +++ b/bot.js @@ -264,7 +264,7 @@ const distubeEventFiles = fs for (const file of distubeEventFiles) { const event = require(`./events/distubeEvents/${file}`); if (event) { - client.distube.once(event.name, (...args) => event.execute(...args, client)); + client.distube.on(event.name, (...args) => event.execute(...args, client)); } else { client.distube.on( event.name, diff --git a/commands/music/add.js b/commands/music/add.js new file mode 100644 index 0000000..149df23 --- /dev/null +++ b/commands/music/add.js @@ -0,0 +1,25 @@ +module.exports = { + name: "add", + description: "Add a song to the queue", + category: "music", + usage: "add ", + guildOnly: true, + /** + * @description Executes when the command is called by command handler. + * @author Vachan MN + * @param {Object} message The Message Object of the command. + * @param {String[]} args The Message Content of the received message seperated by spaces (' ') in an array, this excludes prefix and command/alias itself. + */ + + execute(message, args) { + const searchString = args.join(" "); + if (!message.member.voice.channel) return message.reply('YOU ARENT IN A VC!'); + if (!searchString) return message.reply("Please provide a search query!"); + try { + message.channel.sendTyping(); + message.client.distube.play(message, args.join(' '), {unshift: true}); + } catch (e) { + return message.reply(e); + } + }, +}; diff --git a/commands/music/autoplay.js b/commands/music/autoplay.js index 065aed8..e148f9d 100644 --- a/commands/music/autoplay.js +++ b/commands/music/autoplay.js @@ -1,3 +1,5 @@ +const { MessageEmbed } = require('discord.js'); + module.exports = { name: "autoplay", description: "Turn on/off Autoplay", @@ -17,7 +19,13 @@ module.exports = { if (!queue) return message.channel.send(`There is nothing in the queue right now!`) try { const autoplay = queue.toggleAutoplay() - message.channel.send(`AutoPlay: \`${autoplay ? "On" : "Off"}\``) + const emb = new MessageEmbed() + .setColor("0x0099ff") + .setTitle("Autoplay") + .setDescription(`Autoplay is now \`${autoplay ? "enabled" : "disabled"}\``) + .setFooter(`Requested by ${message.author.tag}`) + .setTimestamp() + message.channel.send({ embeds: [emb] }); } catch (e) { message.channel.send(`${e}`) } diff --git a/commands/music/filters.js b/commands/music/filters.js index 05ad975..4292c7d 100644 --- a/commands/music/filters.js +++ b/commands/music/filters.js @@ -1,3 +1,5 @@ +const {MessageEmbed} = require('discord.js'); + module.exports = { name: "filters", description: "Add filters to the playing song", @@ -17,6 +19,12 @@ module.exports = { if (args[0] === "off" && queue.filters?.length) queue.setFilter(false) else if (Object.keys(message.client.distube.filters).includes(args[0])) queue.setFilter(args[0]) else if (args[0]) return message.channel.send(`Not a valid filter`) - message.channel.send(`Current Queue Filter: \`${queue.filters.join(", ") || "Off"}\``) + const emb = new MessageEmbed() + .setColor("0x009910") + .setTitle("Filters") + .setDescription(queue.filters?.length ? queue.filters.join(", ") : "None") + .setFooter(`Requested by ${message.author.tag}`) + .setTimestamp(); + message.channel.send({embeds: [emb]}); }, }; diff --git a/commands/music/play.js b/commands/music/play.js index 1142e60..8fb53fd 100644 --- a/commands/music/play.js +++ b/commands/music/play.js @@ -1,5 +1,3 @@ -const DisTube = require('distube') - module.exports = { name: "play", description: "Play a song", @@ -20,6 +18,7 @@ module.exports = { if (!message.member.voice.channel) return message.reply('YOU ARENT IN A VC!') if (!searchString) return message.reply('Please enter the search string or url') try { + message.channel.sendTyping(); distube.play(message, args.join(' ')); } catch (e) { return message.reply(e) diff --git a/commands/music/previous.js b/commands/music/previous.js index 15c0d7b..372ef7e 100644 --- a/commands/music/previous.js +++ b/commands/music/previous.js @@ -16,8 +16,7 @@ module.exports = { const queue = client.distube.getQueue(message) if (!queue) return message.channel.send(`There is nothing in the queue right now!`) try { - const song = queue.previous() - message.channel.send(`Now playing:\n${song.name}`) + queue.previous() } catch (e) { message.channel.send(`${e}`) } diff --git a/commands/music/repeat.js b/commands/music/repeat.js index 334034e..09bb150 100644 --- a/commands/music/repeat.js +++ b/commands/music/repeat.js @@ -1,3 +1,5 @@ +const {MessageEmbed} = require('discord.js'); + module.exports = { name: "repeat", description: "Select the repeat pattern", @@ -30,6 +32,12 @@ module.exports = { } mode = queue.setRepeatMode(mode) mode = mode ? mode === 2 ? "Repeat queue" : "Repeat song" : "Off" - message.channel.send(`Set repeat mode to \`${mode}\``) + const emb = new MessageEmbed() + .setColor("0x009910") + .setTitle("Repeat") + .setDescription(`Repeat mode is set to ${mode}`) + .setFooter(`Requested by ${message.author.tag}`, message.author.displayAvatarURL()) + .setTimestamp() + message.channel.send({ embeds: [emb] }) }, }; diff --git a/commands/music/resume.js b/commands/music/resume.js index ea747b5..6c6fb2d 100644 --- a/commands/music/resume.js +++ b/commands/music/resume.js @@ -1,3 +1,5 @@ +const { MessageEmbed } = require("discord.js"); + module.exports = { name: "resume", description: "Resume the paused song", @@ -16,6 +18,12 @@ module.exports = { const queue = client.distube.getQueue(message) if (!queue) return message.channel.send(`There is nothing in the queue right now!`) queue.resume() - message.channel.send("Resumed the song for you :)") + const emb = new MessageEmbed() + .setColor("#00ff00") + .setTitle("Resumed") + .setDescription(`Resumed the paused song`) + .setFooter(`Requested by ${message.author.tag}`) + .setTimestamp() + message.channel.send({embeds: [emb]}) }, }; diff --git a/commands/music/seek.js b/commands/music/seek.js index cccaa6b..95e23c1 100644 --- a/commands/music/seek.js +++ b/commands/music/seek.js @@ -1,3 +1,5 @@ +const {MessageEmbed} = require('discord.js'); + module.exports = { name: "seek", description: "seek to a position in the playing song", @@ -19,6 +21,12 @@ module.exports = { const time = Number(args[0]) if (isNaN(time)) return message.channel.send(`Please enter a valid number!`) queue.seek(time) - message.channel.send(`Seeked to ${time}!`) + const emb = new MessageEmbed() + .setColor("0x009910") + .setTitle("Seeked to position!") + .setDescription(`Seeked to position ${time} seconds!`) + .setFooter(`Requested by ${message.author.tag}`) + .setTimestamp(); + message.channel.send({embeds: [emb]}); }, }; diff --git a/commands/music/skip.js b/commands/music/skip.js index bed3627..97b4978 100644 --- a/commands/music/skip.js +++ b/commands/music/skip.js @@ -16,8 +16,7 @@ module.exports = { const queue = client.distube.getQueue(message) if (!queue) return message.channel.send(`There is nothing in the queue right now!`) try { - const song = queue.skip() - message.channel.send(`Skipped! Now playing:\n${song.name}`) + queue.skip(); } catch (e) { message.channel.send(`${e}`) } diff --git a/commands/music/stop.js b/commands/music/stop.js index f9530ad..caa744f 100644 --- a/commands/music/stop.js +++ b/commands/music/stop.js @@ -1,3 +1,5 @@ +const {MessageEmbed} = require('discord.js'); + module.exports = { name: "stop", description: "Stop the playing song", @@ -15,6 +17,10 @@ module.exports = { const queue = message.client.distube.getQueue(message); if (!queue) return message.channel.send(`There is nothing in the queue right now!`); queue.stop(); - message.channel.send(`Stopped!`); + const emb = new MessageEmbed() + .setTitle("Stopped") + .setColor("#ff0000") + .setDescription(`Stopped the playing song`); + message.channel.send({embeds: [emb]}); }, }; diff --git a/commands/music/volume.js b/commands/music/volume.js index 9ecfe07..450f325 100644 --- a/commands/music/volume.js +++ b/commands/music/volume.js @@ -1,3 +1,5 @@ +const {MessageEmbed} = require('discord.js'); + module.exports = { name: "volume", description: "Set the volume of the player", @@ -18,6 +20,12 @@ module.exports = { const volume = parseInt(args[0]) if (isNaN(volume)) return message.channel.send(`Please enter a valid number!`) queue.setVolume(volume) - message.channel.send(`Volume set to \`${volume}\``) + const emb = new MessageEmbed() + .setColor('#0099ff') + .setTitle('Volume') + .setDescription(`Volume set to ${volume}`) + .setFooter(`Requested by ${message.author.username}`) + .setTimestamp() + message.channel.send({embeds: [emb]}) }, }; diff --git a/events/distubeEvents/finish.js b/events/distubeEvents/finish.js index 040a8e0..0ae0c34 100644 --- a/events/distubeEvents/finish.js +++ b/events/distubeEvents/finish.js @@ -21,6 +21,6 @@ const { MessageEmbed } = require('discord.js'); .setDescription(`Finished playing ${queue.songs[0].title}`) .setThumbnail(queue.songs[0].thumbnail) .setTimestamp(); - queue.textChannel.send(emb); + queue.textChannel.send({embeds: [emb]}); }, }; diff --git a/events/distubeEvents/searchDone.js b/events/distubeEvents/searchDone.js index d5435ec..b247b35 100644 --- a/events/distubeEvents/searchDone.js +++ b/events/distubeEvents/searchDone.js @@ -1,5 +1,3 @@ -const { MessageEmbed } = require('discord.js'); - /** * @file disTube search done event. * @author Vachan MN @@ -13,8 +11,9 @@ const { MessageEmbed } = require('discord.js'); * @description Executes the block of code when the Search is completed * @param {Object} message The users search response message * @param {Object} answer The answered message of user + * @param {Object} client The client object */ execute(message, answer, client) { - console.log("SEARCH COMPLETED") + console.log("SEARCH COMPLETED") }, }; diff --git a/events/distubeEvents/searchResult.js b/events/distubeEvents/searchResult.js index b99e165..822225d 100644 --- a/events/distubeEvents/searchResult.js +++ b/events/distubeEvents/searchResult.js @@ -18,7 +18,8 @@ const { MessageEmbed } = require('discord.js'); execute(message, result, client) { let i = 0 //message.channel.send(`**Choose an option from below**\n${result.map(song => `**${++i}**. ${song.name} - \`${song.formattedDuration}\``).join("\n")}\n*Enter anything else or wait 60 seconds to cancel*`) - const embed = new MessageEmbed() + message.channel.sendTyping(); + const embed = new MessageEmbed() .setColor('#0099ff') .setTitle('Search Results') .setDescription(`${result.map(song => `**${++i}**. ${song.name} - \`${song.formattedDuration}\``).join("\n")}`)