Skip to content

Commit

Permalink
[New] updated pause and queue to work with prefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
naseif committed Oct 4, 2021
1 parent 406ad43 commit 6d617bf
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 4 deletions.
37 changes: 36 additions & 1 deletion commands/Music/pause.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,44 @@ const { SlashCommandBuilder } = require("@discordjs/builders");
const { embedMessage } = require("../../modules/embedSimple");

module.exports = {
name: "pause",
args: false,
description: "Pauses the current playing song",
usage: "pause",
async run(message, args, client) {
const queue = client.player.getQueue(message.guild);

if (!queue || !queue.playing)
return await message.channel.send({
embeds: [
embedMessage("#9dcc37", `❌ | There is nothing playing to pause!`),
],
});

try {
if (queue) {
await queue.setPaused(true);
return await message.channel.send({
embeds: [
embedMessage(
"#9dcc37",
`✅ **${
queue.current.title
}** paused [${message.member.toString()}]`
),
],
});
}
} catch (err) {
client.logger(err.message, "error");
await message.channel.send({
embeds: [embedMessage("#9dcc37", "Could not pause the song")],
});
}
},
data: new SlashCommandBuilder()
.setName("pause")
.setDescription("pauses the song"),
.setDescription("Pauses the current playing song"),

async execute(interaction, client) {
await interaction.deferReply();
Expand Down
42 changes: 39 additions & 3 deletions commands/Music/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,43 @@ const { SlashCommandBuilder } = require("@discordjs/builders");
const { embedMessage } = require("../../modules/embedSimple");

module.exports = {
name: "queue",
aliases: ["q"],
args: false,
description: "Shows all queued songs",
usage: "pause",
async run(message, args, client) {
const queue = client.player.getQueue(message.guild);

if (!queue) {
return await message.channel.send({
embeds: [
embedMessage("#9dcc37", `❌ | Nothing to list, Queue is empty`),
],
});
}

const tracks = queue?.tracks?.map(
(track) => `<@${track.requestedBy.id}>, ${track.title}`
);
const queueEmbed = {
color: "#9dcc37",
title: `Queue contains ${queue?.tracks.length} songs!`,
author: {
name: `${message.member.user.username}`,
icon_url: `${message.member.user.avatarURL()}`,
},
description: `${tracks.join("\n")}`,
footer: {
text: `Playing Now: ${queue?.nowPlaying() || "Nothing"}`,
},
};

await message.channel.send({ embeds: [queueEmbed] });
},
data: new SlashCommandBuilder()
.setName("queue")
.setDescription("Shows the current queue"),
.setDescription("Shows all queued songs"),

async execute(interaction, client) {
await interaction.deferReply();
Expand All @@ -23,13 +57,15 @@ module.exports = {
);
const queueEmbed = {
color: "#9dcc37",
title: `Current Queue`,
title: `Queue contains ${queue?.tracks.length} songs!`,
author: {
name: `${interaction.user.username}`,
icon_url: `${interaction.user.avatarURL()}`,
},
description: `${tracks.join("\n")}`,
timestamp: new Date(),
footer: {
text: `Playing Now: ${queue?.nowPlaying() || "Nothing"}`,
},
};

await interaction.followUp({ embeds: [queueEmbed] });
Expand Down

0 comments on commit 6d617bf

Please sign in to comment.