-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from Joehoel/music
feat: ✨ Music update
- Loading branch information
Showing
21 changed files
with
626 additions
and
1,354 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
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,45 @@ | ||
import SlashCommand, { OptionType } from "@/modules/SlashCommand"; | ||
import { Guild, GuildMember, VoiceChannel } from "discord.js"; | ||
|
||
export default new SlashCommand({ | ||
name: "play", | ||
description: "Play a song", | ||
options: [ | ||
{ | ||
name: "query", | ||
type: OptionType.STRING, | ||
description: "The song you want to play", | ||
required: true, | ||
}, | ||
], | ||
async execute(interaction) { | ||
const player = interaction.client.player; | ||
const query = interaction.options.getString("query")!; | ||
const member = interaction.member as GuildMember; | ||
const queue = player.createQueue(interaction.guild!, { | ||
metadata: { | ||
channel: interaction.channel, | ||
}, | ||
}); | ||
|
||
try { | ||
if (!queue.connection) await queue.connect(member.voice.channel as VoiceChannel); | ||
} catch { | ||
queue.destroy(); | ||
return await interaction.reply({ content: "🚫 | Could not join your voice channel!", ephemeral: true }); | ||
} | ||
|
||
await interaction.deferReply(); | ||
|
||
const track = await player | ||
.search(query, { | ||
requestedBy: interaction.user, | ||
}) | ||
.then((x) => x.tracks[0]); | ||
if (!track) return await interaction.followUp({ content: `❌ | Track **${query}** not found!` }); | ||
|
||
queue.play(track); | ||
|
||
return await interaction.followUp({ content: `⏱️ | Loading track **${track.title}**!` }); | ||
}, | ||
}); |
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,28 @@ | ||
import { chunk, embed } from "@/lib/helpers"; | ||
import SlashCommand, { OptionType } from "@/modules/SlashCommand"; | ||
import { GuildMember, MessageEmbed, VoiceChannel } from "discord.js"; | ||
import { sendPaginatedEmbeds } from "discord.js-embed-pagination"; | ||
|
||
export default new SlashCommand({ | ||
name: "queue", | ||
description: "Get the queue", | ||
async execute(interaction) { | ||
const client = interaction.client; | ||
const queue = client.player.getQueue(interaction.guild!); | ||
|
||
// if (queue.tracks.length > 1) { | ||
// } | ||
// if (queue && queue.songs.length > 1) { | ||
// const formattedQueue = queue?.songs?.map((song, i) => { | ||
// return `**${i + 1}**. \`${song?.name}\` - \`${song?.formattedDuration}\``; | ||
// }); | ||
|
||
// // const paginatedEmbed = new MessageEmbed({ | ||
// // title: "Queue", | ||
// // footer: { text: `${queue?.songs.length} songs in queue | ${queue?.formattedDuration} total length` }, | ||
// // }); | ||
|
||
// await sendPaginatedEmbeds(interaction, embeds); | ||
// } | ||
}, | ||
}); |
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
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
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
Oops, something went wrong.