Skip to content

Commit

Permalink
Music Command Update
Browse files Browse the repository at this point in the history
- Utilises Musicard for songs
- Displays username for queue
  • Loading branch information
TecEash1 committed Oct 25, 2023
1 parent a239d78 commit 0306dac
Show file tree
Hide file tree
Showing 5 changed files with 303 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ for (const folder of triggerFolders) {

// Music Commands

const musicCommandHandler = require('./music_index');
const musicCommandHandler = require('./music_index.js');

const plugins = [
new SpotifyPlugin(),
Expand Down
2 changes: 1 addition & 1 deletion interactions/slash/misc/music.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ module.exports = {
}
case "queue":
embed.setColor("Green").setDescription(`${queue.songs.map(
(song, id) => `\n**${id + 1}.** ${song.name} -\` ${song.formattedDuration} \``
(song, id) => `\n**${id + 1}.** ${song.name} -\` ${song.formattedDuration}\` | ${song.user} `
)}`);
return interaction.reply({ embeds: [embed], ephemeral: true});

Expand Down
41 changes: 34 additions & 7 deletions music_index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,45 @@
const { EmbedBuilder } = require("discord.js");
const { musicCard } = require("musicard");
const fs = require("fs");

const status = queue =>
`Volume: \`${queue.volume}%\` | Filter: \`${queue.filters.names.join(', ') || 'Off'}\` | Loop: \`${queue.repeatMode ? (queue.repeatMode === 2 ? 'All Queue' : 'This Song') : 'Off'
}\` | Autoplay: \`${queue.autoplay ? 'On' : 'Off'}\``

module.exports = (client) => {

client.distube
.on('playSong', (queue, song) =>
queue.textChannel.send({
embeds: [new EmbedBuilder().setColor("Green")
.setDescription(`🎶 | Playing \`${song.name}\` - \`${song.formattedDuration}\`\nRequested by: ${song.user
}\n${status(queue)}`)]
})
)
.on('playSong', (queue, song) => {
const songInfo = {
name: song.name,
user: song.user,
thumbnail: song.thumbnail,
formattedDuration: song.formattedDuration,
};


const card = new musicCard()
.setName(songInfo.name)
.setAuthor(`‣ ${songInfo.user.username}`)
.setColor("auto")
.setTheme("classic")
.setBrightness(50)
.setThumbnail(songInfo.thumbnail)
.setProgress(queue.volume)
.setStartTime(`Volume: ${queue.volume}%`)
.setEndTime(songInfo.formattedDuration)


async function buildAndSendCard() {
const cardBuffer = await card.build();
fs.writeFileSync(`musicard.png`, cardBuffer);

queue.textChannel.send({
files: [`musicard.png`],
});
}
buildAndSendCard();
})
.on('addSong', (queue, song) =>
queue.textChannel.send(
{
Expand Down
267 changes: 265 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0306dac

Please sign in to comment.