-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEAT: close to finishing music management, UP version
- Loading branch information
1 parent
26a09c6
commit ec70a5b
Showing
6 changed files
with
123 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, ButtonStyle, ButtonBuilder, ComponentType } = require('discord.js'); | ||
const { useMainPlayer, useQueue } = require('discord-player'); | ||
|
||
module.exports = { | ||
data: new SlashCommandBuilder() | ||
.setName('music') | ||
.setDescription('Music manager dashboard'), | ||
async execute(interaction) { | ||
|
||
const player = useMainPlayer(); | ||
const channel = interaction.member.voice.channelId; | ||
const queue = useQueue(interaction.guild.id); | ||
const currentTrack = queue.currentTrack; | ||
const tracksArray = queue.tracks.toArray(); | ||
if (!channel) return interaction.reply('You are not connected to a voice channel!'); // make sure we have a voice channel | ||
|
||
const playPause = new ButtonBuilder() | ||
.setCustomId('playpause') | ||
.setLabel('⏯') | ||
.setStyle(ButtonStyle.Primary); | ||
|
||
const skip = new ButtonBuilder() | ||
.setCustomId('skip') | ||
.setLabel('⏭') | ||
.setStyle(ButtonStyle.Secondary); | ||
|
||
const clear = new ButtonBuilder() | ||
.setCustomId('clear') | ||
.setLabel('❌') | ||
.setStyle(ButtonStyle.Danger); | ||
|
||
|
||
const row = new ActionRowBuilder() | ||
.addComponents(playPause, skip, clear); | ||
|
||
const embed = new EmbedBuilder(); | ||
|
||
embed | ||
.setTitle(`${currentTrack}`) | ||
.setDescription(`Next track: ${tracksArray[0]}`) | ||
.setThumbnail(`${currentTrack.thumbnail}`) | ||
.addFields({ name: `Duration:`, value: `${currentTrack.duration}`, inline: true }, | ||
{ name: 'Songs left:', value: `${queue.getSize()}`, inline: true } | ||
); | ||
|
||
|
||
const reply = await interaction.reply({ | ||
content: `_ _`, | ||
embeds: [embed], | ||
components: [row], | ||
}); | ||
|
||
const collector = reply.createMessageComponentCollector({ componentType: ComponentType.StringSelect, time: 3_600_000 }); | ||
|
||
const collectorFilter = i => i.user.id === interaction.user.id; | ||
|
||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
function buttonIdHandler(id, msg) { | ||
|
||
const { useMainPlayer, useQueue } = require('discord-player'); | ||
const { guildId } = require('../../config.json'); | ||
const queue = useQueue(guildId); | ||
const currentTrack = queue.currentTrack; | ||
|
||
switch(id) { | ||
case "playpause": | ||
queue.node.setPaused(!queue.node.isPaused()); | ||
if (!queue.node.isPaused()) { | ||
msg.edit(`Resuming **${currentTrack}**`); | ||
} else { | ||
msg.edit(`Paused player`); | ||
} | ||
break; | ||
|
||
case "skip": | ||
msg.edit(`Skipping **${currentTrack}**`) | ||
queue.node.skip(); | ||
break; | ||
|
||
case "clear": | ||
msg.delete(); | ||
break; | ||
|
||
default: | ||
msg.edit(`**Achievement get:** How did we get here?\nSeriously how did you get an invalid ID`); | ||
|
||
} | ||
|
||
} | ||
|
||
module.exports = { | ||
buttonIdHandler, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters