Skip to content
This repository has been archived by the owner on Jun 18, 2022. It is now read-only.

Commit

Permalink
embeds!
Browse files Browse the repository at this point in the history
  • Loading branch information
vachanmn123 committed Nov 4, 2021
1 parent 17fecce commit 4ac5b78
Show file tree
Hide file tree
Showing 15 changed files with 95 additions and 19 deletions.
2 changes: 1 addition & 1 deletion bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
25 changes: 25 additions & 0 deletions commands/music/add.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
name: "add",
description: "Add a song to the queue",
category: "music",
usage: "add <search query>",
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);
}
},
};
10 changes: 9 additions & 1 deletion commands/music/autoplay.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { MessageEmbed } = require('discord.js');

module.exports = {
name: "autoplay",
description: "Turn on/off Autoplay",
Expand All @@ -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}`)
}
Expand Down
10 changes: 9 additions & 1 deletion commands/music/filters.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const {MessageEmbed} = require('discord.js');

module.exports = {
name: "filters",
description: "Add filters to the playing song",
Expand All @@ -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]});
},
};
3 changes: 1 addition & 2 deletions commands/music/play.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const DisTube = require('distube')

module.exports = {
name: "play",
description: "Play a song",
Expand All @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions commands/music/previous.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}
Expand Down
10 changes: 9 additions & 1 deletion commands/music/repeat.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const {MessageEmbed} = require('discord.js');

module.exports = {
name: "repeat",
description: "Select the repeat pattern",
Expand Down Expand Up @@ -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] })
},
};
10 changes: 9 additions & 1 deletion commands/music/resume.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { MessageEmbed } = require("discord.js");

module.exports = {
name: "resume",
description: "Resume the paused song",
Expand All @@ -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]})
},
};
10 changes: 9 additions & 1 deletion commands/music/seek.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const {MessageEmbed} = require('discord.js');

module.exports = {
name: "seek",
description: "seek to a position in the playing song",
Expand All @@ -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]});
},
};
3 changes: 1 addition & 2 deletions commands/music/skip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}
Expand Down
8 changes: 7 additions & 1 deletion commands/music/stop.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const {MessageEmbed} = require('discord.js');

module.exports = {
name: "stop",
description: "Stop the playing song",
Expand All @@ -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]});
},
};
10 changes: 9 additions & 1 deletion commands/music/volume.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const {MessageEmbed} = require('discord.js');

module.exports = {
name: "volume",
description: "Set the volume of the player",
Expand All @@ -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]})
},
};
2 changes: 1 addition & 1 deletion events/distubeEvents/finish.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]});
},
};
5 changes: 2 additions & 3 deletions events/distubeEvents/searchDone.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const { MessageEmbed } = require('discord.js');

/**
* @file disTube search done event.
* @author Vachan MN
Expand All @@ -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")
},
};
3 changes: 2 additions & 1 deletion events/distubeEvents/searchResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")}`)
Expand Down

0 comments on commit 4ac5b78

Please sign in to comment.