mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-02 14:38:49 +00:00
Updated interaction reply to have embed with color
This commit is contained in:
1 parent
7437f67cbe
commit
4a7bf9ecb9
4 files changed
+113
-50
No files matched your search
+18
-6
@@ -8,17 +8,27 @@ module.exports = {
|
||||
.setDescription('Pause the currently playing track.'),
|
||||
run: async ({ interaction }) => {
|
||||
if (!interaction.member.voice.channel) {
|
||||
return interaction.editReply(
|
||||
'You need to be in a voice channel to use this command.'
|
||||
);
|
||||
return interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`You need to be in a voice channel to use this command.`
|
||||
)
|
||||
.setColor('#c70057')
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
const queue = useQueue(interaction.guild.id);
|
||||
|
||||
if (!queue) {
|
||||
return await interaction.editReply(
|
||||
'There are no tracks in the queue.'
|
||||
);
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(`There are no tracks in the queue.`)
|
||||
.setColor('#c70057')
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
// change paused state to opposite of current state
|
||||
@@ -35,6 +45,7 @@ module.exports = {
|
||||
`**Paused**\n**[${queue.currentTrack.title}](${queue.currentTrack.url})**.`
|
||||
)
|
||||
.setThumbnail(queue.currentTrack.thumbnail)
|
||||
.setColor('#4c73df')
|
||||
]
|
||||
});
|
||||
} else {
|
||||
@@ -49,6 +60,7 @@ module.exports = {
|
||||
`**Resumed**\n**[${queue.currentTrack.title}](${queue.currentTrack.url})**.`
|
||||
)
|
||||
.setThumbnail(queue.currentTrack.thumbnail)
|
||||
.setColor('#4c73df')
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
+10
-3
@@ -14,9 +14,15 @@ module.exports = {
|
||||
),
|
||||
run: async ({ interaction }) => {
|
||||
if (!interaction.member.voice.channel) {
|
||||
return interaction.editReply(
|
||||
'You need to be in a voice channel to use this command.'
|
||||
);
|
||||
return interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`You need to be in a voice channel to use this command.`
|
||||
)
|
||||
.setColor('#c70057')
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
const player = useMainPlayer();
|
||||
@@ -48,6 +54,7 @@ module.exports = {
|
||||
`**Added to queue**\n\`[${track.duration}]\` **[${track.title}](${track.url})**`
|
||||
)
|
||||
.setThumbnail(track.thumbnail)
|
||||
.setColor('#4c73df')
|
||||
]
|
||||
});
|
||||
} catch (e) {
|
||||
|
||||
+76
-38
@@ -1,5 +1,5 @@
|
||||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||
const { useMainPlayer, useQueue } = require('discord-player');
|
||||
const { useQueue } = require('discord-player');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
@@ -14,30 +14,50 @@ module.exports = {
|
||||
),
|
||||
run: async ({ interaction }) => {
|
||||
if (!interaction.member.voice.channel) {
|
||||
return interaction.editReply(
|
||||
'You need to be in a voice channel to use this command.'
|
||||
);
|
||||
return interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`You need to be in a voice channel to use this command.`
|
||||
)
|
||||
.setColor('#c70057')
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
const queue = useQueue(interaction.guild.id);
|
||||
let queueString = '';
|
||||
|
||||
if (!queue) {
|
||||
return await interaction.editReply(
|
||||
'There are no tracks in the queue.'
|
||||
);
|
||||
queueString = 'There are no tracks in the queue.';
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: interaction.guild.name,
|
||||
iconURL: interaction.guild.iconURL()
|
||||
})
|
||||
.setDescription(`**Queue**\n${queueString}`)
|
||||
.setColor('#4c73df')
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
const totalPages = Math.ceil(queue.tracks.data.length / 10) || 1;
|
||||
const page = (interaction.options.getNumber('page') || 1) - 1;
|
||||
|
||||
if (page > totalPages - 1) {
|
||||
return await interaction.editReply(
|
||||
`Invalid page number. There are only a total of ${totalPages} pages of tracks.`
|
||||
);
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`Invalid page number. There are only a total of ${totalPages} pages of tracks.`
|
||||
)
|
||||
.setColor('#c70057')
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
let queueString = '';
|
||||
|
||||
if (queue.tracks.data.length === 0) {
|
||||
queueString = 'There are no tracks in the queue.';
|
||||
} else {
|
||||
@@ -53,32 +73,50 @@ module.exports = {
|
||||
|
||||
let currentTrack = queue.currentTrack;
|
||||
|
||||
let bar = queue.node.createProgressBar({
|
||||
queue: false,
|
||||
length: 13
|
||||
});
|
||||
if (!currentTrack) {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: interaction.guild.name,
|
||||
iconURL: interaction.guild.iconURL()
|
||||
})
|
||||
.setDescription(`**Queue**\n${queueString}`)
|
||||
.setFooter({
|
||||
text: `Page ${page + 1} of ${totalPages}`
|
||||
})
|
||||
.setColor('#4c73df')
|
||||
]
|
||||
});
|
||||
} else {
|
||||
let bar = queue.node.createProgressBar({
|
||||
queue: false,
|
||||
length: 13
|
||||
});
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: interaction.guild.name,
|
||||
iconURL: interaction.guild.iconURL()
|
||||
})
|
||||
.setDescription(
|
||||
`**Currently playing**\n` +
|
||||
(currentTrack
|
||||
? `**[${currentTrack.title}](${currentTrack.url})**`
|
||||
: 'None') +
|
||||
`\nRequested by: <@${currentTrack.requestedBy.id}>` +
|
||||
`\n ${bar}` +
|
||||
`\n\n**Queue**\n${queueString}`
|
||||
)
|
||||
.setThumbnail(queue.currentTrack.thumbnail)
|
||||
.setFooter({
|
||||
text: `Page ${page + 1} of ${totalPages}`
|
||||
})
|
||||
]
|
||||
});
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: interaction.guild.name,
|
||||
iconURL: interaction.guild.iconURL()
|
||||
})
|
||||
.setDescription(
|
||||
`**Currently playing**\n` +
|
||||
(currentTrack
|
||||
? `**[${currentTrack.title}](${currentTrack.url})**`
|
||||
: 'None') +
|
||||
`\nRequested by: <@${currentTrack.requestedBy.id}>` +
|
||||
`\n ${bar}` +
|
||||
`\n\n**Queue**\n${queueString}`
|
||||
)
|
||||
.setThumbnail(queue.currentTrack.thumbnail)
|
||||
.setFooter({
|
||||
text: `Page ${page + 1} of ${totalPages}`
|
||||
})
|
||||
.setColor('#4c73df')
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -76,9 +76,15 @@ client.on('interactionCreate', async (interaction) => {
|
||||
`Command '/${interaction.commandName}' failed unexpectedly.`
|
||||
);
|
||||
|
||||
await interaction.editReply(
|
||||
'There was an error while executing this command!'
|
||||
);
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`There was an error while executing this command!`
|
||||
)
|
||||
.setColor('#c70057')
|
||||
]
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user