Skip to content

Commit a251ef4

Browse files
committed
Add clear command, tweak UI text
1 parent b3d45e6 commit a251ef4

3 files changed

Lines changed: 68 additions & 16 deletions

File tree

src/commands/chatplay.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ module.exports = {
8787
const reply = new ContainerBuilder();
8888
reply.addTextDisplayComponents(
8989
new TextDisplayBuilder().setContent(
90-
"### ChatPlay Enabled\n\n" +
91-
"**Status**\n" +
92-
"-# Listening for song requests.\n\n" +
93-
"**Channel**\n" +
90+
"### ChatPlay Enabled" +
91+
"**Status**" +
92+
"-# Listening for song requests." +
93+
"**Channel**" +
9494
`-# <#${guildData.chatPlayChannelId}>`
9595
)
9696
);

src/commands/clear.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const { SlashCommandBuilder, MessageFlags, ContainerBuilder, TextDisplayBuilder } = require("discord.js");
2+
3+
module.exports = {
4+
data: new SlashCommandBuilder()
5+
.setName("clear")
6+
.setDescription("Clear the queue without stopping the current track"),
7+
8+
async execute(interaction, client) {
9+
const player = client.riffy.players.get(interaction.guild.id);
10+
11+
if (!player) {
12+
return interaction.reply({
13+
content: "❌ No active player.",
14+
flags: MessageFlags.Ephemeral,
15+
});
16+
}
17+
18+
if (!interaction.member.voice?.channel) {
19+
return interaction.reply({
20+
content: "❌ You need to be in a voice channel!",
21+
flags: MessageFlags.Ephemeral,
22+
});
23+
}
24+
25+
const queueLength = player.queue?.length || 0;
26+
27+
if (queueLength === 0) {
28+
return interaction.reply({
29+
content: "❌ The queue is already empty.",
30+
flags: MessageFlags.Ephemeral,
31+
});
32+
}
33+
34+
player.queue.clear();
35+
36+
const container = new ContainerBuilder();
37+
container.addTextDisplayComponents(
38+
new TextDisplayBuilder().setContent(
39+
"### 🗑️ Queue Cleared\n\n" +
40+
"**Removed**\n" +
41+
`-# ${queueLength} track${queueLength === 1 ? "" : "s"} removed from queue\n\n` +
42+
"**Now Playing**\n" +
43+
`-# ${player.current?.info?.title || "Nothing"}`
44+
)
45+
);
46+
47+
await interaction.reply({
48+
components: [container],
49+
flags: MessageFlags.Ephemeral | MessageFlags.IsComponentsV2,
50+
});
51+
},
52+
};

src/utils/components.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ function createNowPlayingContainer(track, player, guildData, musicardBuffer) {
5858
// --- Status: Autoplay / Loop / Volume ---
5959
container.addTextDisplayComponents(
6060
new TextDisplayBuilder().setContent(
61-
"**Autoplay**\n" +
62-
`-# ${guildData.autoplay ? "On" : "Off"}\n\n` +
63-
"**Loop**\n" +
64-
`-# ${capitalize(guildData.loop)}\n\n` +
65-
"**Volume**\n" +
61+
"**Autoplay**" +
62+
`-# ${guildData.autoplay ? "On" : "Off"}` +
63+
"**Loop**" +
64+
`-# ${capitalize(guildData.loop)}` +
65+
"**Volume**" +
6666
`-# ${guildData.volume}%`
6767
)
6868
);
@@ -72,7 +72,7 @@ function createNowPlayingContainer(track, player, guildData, musicardBuffer) {
7272

7373
// --- Next on Deck ---
7474
const queue = player.queue;
75-
let nextContent = "**Next on Deck**\n\n";
75+
let nextContent = "**Next on Deck**\n";
7676
if (queue && queue.length > 0) {
7777
const upcoming = queue.slice(0, 3);
7878
for (let i = 0; i < upcoming.length; i++) {
@@ -265,11 +265,11 @@ function createChatPlayNowPlayingContainer(track, player, guildData, musicardBuf
265265
// --- Status: Autoplay / Loop / Volume ---
266266
container.addTextDisplayComponents(
267267
new TextDisplayBuilder().setContent(
268-
"**Autoplay**\n" +
269-
`-# ${guildData.autoplay ? "On" : "Off"}\n\n` +
270-
"**Loop**\n" +
271-
`-# ${capitalize(guildData.loop)}\n\n` +
272-
"**Volume**\n" +
268+
"**Autoplay**" +
269+
`-# ${guildData.autoplay ? "On" : "Off"}` +
270+
"**Loop**" +
271+
`-# ${capitalize(guildData.loop)}` +
272+
"**Volume**" +
273273
`-# ${guildData.volume}%`
274274
)
275275
);
@@ -279,7 +279,7 @@ function createChatPlayNowPlayingContainer(track, player, guildData, musicardBuf
279279

280280
// --- Next on Deck ---
281281
const queue = player.queue;
282-
let nextContent = "**Next on Deck**\n\n";
282+
let nextContent = "**Next on Deck**\n";
283283
if (queue && queue.length > 0) {
284284
const upcoming = queue.slice(0, 3);
285285
for (let i = 0; i < upcoming.length; i++) {

0 commit comments

Comments
 (0)