|
1 |
| -const { EmbedBuilder, escapeMarkdown, AttachmentBuilder } = require("discord.js"); |
| 1 | +const { |
| 2 | + EmbedBuilder, |
| 3 | + escapeMarkdown, |
| 4 | + AttachmentBuilder, |
| 5 | +} = require("discord.js"); |
2 | 6 | const SlashCommand = require("../../lib/SlashCommand");
|
3 |
| -const createCard = require("songcard"); |
| 7 | +const { classicCard } = require("songcard"); |
4 | 8 | const path = require("path");
|
5 | 9 |
|
6 | 10 | const command = new SlashCommand()
|
7 |
| - .setName("nowplaying") |
8 |
| - .setDescription("Shows the song currently playing in the voice channel.") |
9 |
| - .setRun(async (client, interaction, options) => { |
10 |
| - let channel = await client.getChannel(client, interaction); |
11 |
| - if (!channel) { |
12 |
| - return; |
13 |
| - } |
| 11 | + .setName("nowplaying") |
| 12 | + .setDescription("Shows the song currently playing in the voice channel.") |
| 13 | + .setRun(async (client, interaction, options) => { |
| 14 | + let channel = await client.getChannel(client, interaction); |
| 15 | + if (!channel) { |
| 16 | + return; |
| 17 | + } |
14 | 18 |
|
15 |
| - let player; |
16 |
| - if (client.manager.Engine) { |
17 |
| - player = client.manager.Engine.players.get(interaction.guild.id); |
18 |
| - } else { |
19 |
| - return interaction.reply({ |
20 |
| - embeds: [ |
21 |
| - new EmbedBuilder() |
22 |
| - .setColor("Red") |
23 |
| - .setDescription("Lavalink node is not connected"), |
24 |
| - ], |
25 |
| - }); |
26 |
| - } |
| 19 | + let player; |
| 20 | + if (client.manager.Engine) { |
| 21 | + player = client.manager.Engine.players.get(interaction.guild.id); |
| 22 | + } else { |
| 23 | + return interaction.reply({ |
| 24 | + embeds: [ |
| 25 | + new EmbedBuilder() |
| 26 | + .setColor("Red") |
| 27 | + .setDescription("Lavalink node is not connected"), |
| 28 | + ], |
| 29 | + }); |
| 30 | + } |
27 | 31 |
|
28 |
| - if (!player) { |
29 |
| - return interaction.reply({ |
30 |
| - embeds: [ |
31 |
| - new EmbedBuilder() |
32 |
| - .setColor("Red") |
33 |
| - .setDescription("The bot isn't in a channel."), |
34 |
| - ], |
35 |
| - ephemeral: true, |
36 |
| - }); |
37 |
| - } |
| 32 | + if (!player) { |
| 33 | + return interaction.reply({ |
| 34 | + embeds: [ |
| 35 | + new EmbedBuilder() |
| 36 | + .setColor("Red") |
| 37 | + .setDescription("The bot isn't in a channel."), |
| 38 | + ], |
| 39 | + ephemeral: true, |
| 40 | + }); |
| 41 | + } |
38 | 42 |
|
39 |
| - if (!player.playing) { |
40 |
| - return interaction.reply({ |
41 |
| - embeds: [ |
42 |
| - new EmbedBuilder() |
43 |
| - .setColor("Red") |
44 |
| - .setDescription("There's nothing playing."), |
45 |
| - ], |
46 |
| - ephemeral: true, |
47 |
| - }); |
48 |
| - } |
| 43 | + if (!player.playing) { |
| 44 | + return interaction.reply({ |
| 45 | + embeds: [ |
| 46 | + new EmbedBuilder() |
| 47 | + .setColor("Red") |
| 48 | + .setDescription("There's nothing playing."), |
| 49 | + ], |
| 50 | + ephemeral: true, |
| 51 | + }); |
| 52 | + } |
49 | 53 |
|
50 |
| - const song = player.queue.current; |
| 54 | + const song = player.queue.current; |
51 | 55 |
|
52 |
| - const noBgURL = path.join(__dirname, "..", "..", "assets", "no_bg.png"); |
| 56 | + const noBgURL = path.join(__dirname, "..", "..", "assets", "no_bg.png"); |
53 | 57 |
|
54 |
| - const cardImage = await createCard( |
55 |
| - (imageBg = song.displayThumbnail("maxresdefault") || noBgURL), |
56 |
| - (imageText = song.title), |
57 |
| - (trackStream = song.isStream), |
58 |
| - (trackDuration = player.position), |
59 |
| - (trackTotalDuration = song.duration) |
60 |
| - ); |
| 58 | + const cardImage = await classicCard({ |
| 59 | + imageBg: song.displayThumbnail("maxresdefault") || noBgURL, |
| 60 | + imageText: song.title, |
| 61 | + trackStream: song.isStream, |
| 62 | + trackDuration: player.position, |
| 63 | + trackTotalDuration: song.duration, |
| 64 | + }); |
61 | 65 |
|
62 |
| - const attachment = new AttachmentBuilder(cardImage, { name: "card.png" }); |
| 66 | + const attachment = new AttachmentBuilder(cardImage, { name: "card.png" }); |
63 | 67 |
|
64 |
| - var title = escapeMarkdown(song.title); |
65 |
| - var title = title.replace(/\]/g, ""); |
66 |
| - var title = title.replace(/\[/g, ""); |
67 |
| - const embed = new EmbedBuilder() |
68 |
| - .setColor(client.config.embedColor) |
69 |
| - .setAuthor({ name: "Now Playing", iconURL: client.config.iconURL }) |
70 |
| - // show who requested the song via setField, also show the duration of the song |
71 |
| - .setFields([ |
72 |
| - { |
73 |
| - name: "Requested by", |
74 |
| - value: `<@${song.requester.id}>`, |
75 |
| - inline: true, |
76 |
| - }, |
77 |
| - ]) |
78 |
| - .setDescription(`[${title}](${song.uri})`) |
79 |
| - .setImage("attachment://card.png"); |
80 |
| - return interaction.reply({ embeds: [embed], files: [attachment] }); |
81 |
| - }); |
| 68 | + var title = escapeMarkdown(song.title); |
| 69 | + var title = title.replace(/\]/g, ""); |
| 70 | + var title = title.replace(/\[/g, ""); |
| 71 | + const embed = new EmbedBuilder() |
| 72 | + .setColor(client.config.embedColor) |
| 73 | + .setAuthor({ name: "Now Playing", iconURL: client.config.iconURL }) |
| 74 | + // show who requested the song via setField, also show the duration of the song |
| 75 | + .setFields([ |
| 76 | + { |
| 77 | + name: "Requested by", |
| 78 | + value: `<@${song.requester.id}>`, |
| 79 | + inline: true, |
| 80 | + }, |
| 81 | + ]) |
| 82 | + .setDescription(`[${title}](${song.uri})`) |
| 83 | + .setImage("attachment://card.png"); |
| 84 | + return interaction.reply({ embeds: [embed], files: [attachment] }); |
| 85 | + }); |
82 | 86 | module.exports = command;
|
0 commit comments