From 4885398f05c73eac12eb4cab9790d5df2386ccc5 Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Wed, 12 Jul 2023 14:21:02 +0200 Subject: [PATCH] fix: reply with "started playing" when adding track to empty queue --- commands/play.js | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/commands/play.js b/commands/play.js index 84f6951..3761b97 100644 --- a/commands/play.js +++ b/commands/play.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require('@discordjs/builders'); -const { useMainPlayer } = require('discord-player'); +const { useMainPlayer, useQueue } = require('discord-player'); const { EmbedBuilder } = require('discord.js'); const { embedColors, playerOptions } = require('../config.json'); @@ -83,6 +83,20 @@ module.exports = { } ); + const queue = useQueue(interaction.guild.id); + + if (!queue) { + return await interaction.editReply({ + embeds: [ + new EmbedBuilder() + .setDescription( + `**Failed**\nFailed to add track to queue. Please try again.` + ) + .setColor(embedColors.colorError) + ] + }); + } + if (track.source === 'arbitrary') { track.thumbnail = 'https://raw.githubusercontent.com/mariusbegby/cadence-discord-bot/main/icons/Cadence-icon-rounded-128px.png'; @@ -114,6 +128,23 @@ module.exports = { }); } + if (queue.currentTrack === track) { + return await interaction.editReply({ + embeds: [ + new EmbedBuilder() + .setAuthor({ + name: interaction.user.username, + iconURL: interaction.user.avatarURL() + }) + .setDescription( + `**Started playing**\n${durationFormat} **[${track.title}](${track.url})**` + ) + .setThumbnail(track.thumbnail) + .setColor(embedColors.colorSuccess) + ] + }); + } + return await interaction.editReply({ embeds: [ new EmbedBuilder()