mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-01 22:14:59 +00:00
92 lines
3.6 KiB
JavaScript
92 lines
3.6 KiB
JavaScript
const { SlashCommandBuilder } = require('@discordjs/builders');
|
|
const { useQueue } = require('discord-player');
|
|
const { EmbedBuilder } = require('discord.js');
|
|
const { embedColors, embedIcons } = require('../config.json');
|
|
|
|
module.exports = {
|
|
data: new SlashCommandBuilder()
|
|
.setName('pause')
|
|
.setDescription('Pause or resume the current track.')
|
|
.setDMPermission(false),
|
|
run: async ({ interaction }) => {
|
|
if (!interaction.member.voice.channel) {
|
|
return await interaction.editReply({
|
|
embeds: [
|
|
new EmbedBuilder()
|
|
.setDescription(
|
|
`**${embedIcons.warning} Oops!**\nYou need to be in a voice channel to use this command.`
|
|
)
|
|
.setColor(embedColors.colorWarning)
|
|
]
|
|
});
|
|
}
|
|
|
|
const queue = useQueue(interaction.guild.id);
|
|
|
|
if (!queue) {
|
|
return await interaction.editReply({
|
|
embeds: [
|
|
new EmbedBuilder()
|
|
.setDescription(
|
|
`**${embedIcons.warning} Oops!**\nThere are no tracks in the queue and nothing currently playing. First add some tracks with \`/play\`!`
|
|
)
|
|
.setColor(embedColors.colorWarning)
|
|
]
|
|
});
|
|
}
|
|
|
|
if (!queue.currentTrack) {
|
|
return await interaction.editReply({
|
|
embeds: [
|
|
new EmbedBuilder()
|
|
.setDescription(
|
|
`**${embedIcons.warning} Oops!**\nThere is nothing currently playing. First add some tracks with \`/play\`!`
|
|
)
|
|
.setColor(embedColors.colorWarning)
|
|
]
|
|
});
|
|
}
|
|
|
|
let durationFormat =
|
|
queue.currentTrack.raw.duration === 0 ||
|
|
queue.currentTrack.duration === '0:00'
|
|
? ''
|
|
: `\`${queue.currentTrack.duration}\``;
|
|
|
|
// change paused state to opposite of current state
|
|
queue.node.setPaused(!queue.node.isPaused());
|
|
|
|
if (queue.node.isPaused()) {
|
|
return await interaction.editReply({
|
|
embeds: [
|
|
new EmbedBuilder()
|
|
.setAuthor({
|
|
name: interaction.member.nickname || interaction.user.username,
|
|
iconURL: interaction.user.avatarURL()
|
|
})
|
|
.setDescription(
|
|
`**${embedIcons.pauseResumed} Paused track**\n**${durationFormat} [${queue.currentTrack.title}](${queue.currentTrack.url})**`
|
|
)
|
|
.setThumbnail(queue.currentTrack.thumbnail)
|
|
.setColor(embedColors.colorSuccess)
|
|
]
|
|
});
|
|
} else {
|
|
return await interaction.editReply({
|
|
embeds: [
|
|
new EmbedBuilder()
|
|
.setAuthor({
|
|
name: interaction.member.nickname || interaction.user.username,
|
|
iconURL: interaction.user.avatarURL()
|
|
})
|
|
.setDescription(
|
|
`**${embedIcons.pauseResumed} Resumed track**\n**${durationFormat} [${queue.currentTrack.title}](${queue.currentTrack.url})**`
|
|
)
|
|
.setThumbnail(queue.currentTrack.thumbnail)
|
|
.setColor(embedColors.colorSuccess)
|
|
]
|
|
});
|
|
}
|
|
}
|
|
};
|