Added music commands

This commit is contained in:
2024-02-09 20:09:27 +01:00
parent d45c9fa299
commit d167e90316
6 changed files with 193 additions and 3 deletions

View File

@@ -0,0 +1,41 @@
import { embedColor } from "config/options"
import { useMainPlayer } from "discord-player"
import { ChatInputCommandInteraction, GuildMember } from "discord.js"
export default async function play(interaction: ChatInputCommandInteraction) {
await interaction.deferReply()
const query = interaction.options.getString("query")!
const channel = (interaction.member as GuildMember).voice.channel
const player = useMainPlayer()
if (!channel) {
await interaction.editReply({
embeds: [{
description: "You need to be in a voice channel to play music",
color: embedColor
}]
})
return
}
const { track } = await player.play(channel, query, {
requestedBy: interaction.user,
nodeOptions: {
volume: 50,
}
})
await interaction.editReply({
embeds: [{
description: `Playing [${track.title}](${track.url})`,
thumbnail: {
url: track.thumbnail
},
color: embedColor,
footer: {
text: track.duration + " minutes",
icon_url: interaction.user.avatarURL()!
}
}]
})
}