Updated music commands

This commit is contained in:
2024-02-10 16:03:46 +01:00
parent cbeeeca8d8
commit 23a7db55e1
8 changed files with 137 additions and 12 deletions

View File

@@ -10,25 +10,27 @@ export default async function nowplaying(interaction: ChatInputCommandInteractio
if (!queue) {
await interaction.editReply({
content: "There is no queue"
embeds: [{
description: "There is no music playing",
color: embedColor
}]
})
return
}
const current = queue.currentTrack
if (!current) {
await interaction.editReply({
content: "There is no current song"
embeds: [{
description: "There is no music playing",
color: embedColor
}]
})
return
}
await interaction.editReply({
embeds: [{
author: {
name: current.author,
},
title: "Now Playing",
description: `[${current.title}](${current.url})`,
color: embedColor,

View File

@@ -0,0 +1,38 @@
import { embedColor } from "config/options"
import { useMainPlayer } from "discord-player"
import { ChatInputCommandInteraction } from "discord.js"
export default async function pause(interaction: ChatInputCommandInteraction) {
await interaction.deferReply()
const player = useMainPlayer()
const queue = player.queues.get(interaction.guildId!)
if (!queue) {
await interaction.editReply({
embeds: [{
description: "There is no music playing",
color: embedColor
}]
})
return
}
if (queue.node.isPaused()) {
await interaction.editReply({
embeds: [{
description: "The music is already paused",
color: embedColor
}]
})
return
}
queue.node.setPaused(true)
await interaction.editReply({
embeds: [{
description: "Paused the music",
color: embedColor
}]
})
}

View File

@@ -18,6 +18,8 @@ export default async function play(interaction: ChatInputCommandInteraction) {
return
}
// const bitRate = channel.bitrate / 1000
const { track } = await player.play(channel, query, {
requestedBy: interaction.user,
nodeOptions: {

View File

@@ -8,7 +8,12 @@ export default async function queue(interaction: ChatInputCommandInteraction) {
const queue = player.queues.get(interaction.guildId!)
if (!queue) {
await interaction.editReply("There is nothing playing")
await interaction.editReply({
embeds: [{
description: "There is no queue",
color: embedColor
}]
})
return
}
@@ -20,8 +25,15 @@ export default async function queue(interaction: ChatInputCommandInteraction) {
await interaction.editReply({
embeds: [{
title: "Queue",
description: nowPlaying + "\n\n" + tracks.join("\n"),
color: embedColor
thumbnail: {
url: currentSong?.thumbnail || ""
},
color: embedColor,
footer: {
text: `Total tracks: ${queue.tracks.size}`
}
}]
})
}

View File

@@ -1,3 +1,4 @@
import { embedColor } from "config/options"
import { useMainPlayer } from "discord-player"
import { ChatInputCommandInteraction } from "discord.js"
@@ -10,14 +11,20 @@ export default async function skip(interaction: ChatInputCommandInteraction) {
if (!queue) {
await interaction.editReply({
content: "There is no queue"
embeds: [{
description: "There is no queue",
color: embedColor
}]
})
return
}
if (amount > queue.size) {
await interaction.editReply({
content: `There are only ${queue.size} songs in the queue`
embeds: [{
description: `There are only ${queue.size} song${queue.size === 1 ? "" : "s"} in the queue`,
color: embedColor
}]
})
return
}
@@ -29,6 +36,9 @@ export default async function skip(interaction: ChatInputCommandInteraction) {
}
await interaction.editReply({
content: `Skipped ${amount} song${amount === 1 ? "" : "s"}`
embeds: [{
description: `Skipped ${amount === 1 ? "1 song" : `${amount} songs`}`,
color: embedColor
}]
})
}

View File

@@ -0,0 +1,38 @@
import { embedColor } from "config/options"
import { useMainPlayer } from "discord-player"
import { ChatInputCommandInteraction } from "discord.js"
export default async function pause(interaction: ChatInputCommandInteraction) {
await interaction.deferReply()
const player = useMainPlayer()
const queue = player.queues.get(interaction.guildId!)
if (!queue) {
await interaction.editReply({
embeds: [{
description: "There is no music playing",
color: embedColor
}]
})
return
}
if (!queue.node.isPaused()) {
await interaction.editReply({
embeds: [{
description: "The music is not paused",
color: embedColor
}]
})
return
}
queue.node.setPaused(false)
await interaction.editReply({
embeds: [{
description: "Unpaused the music",
color: embedColor
}]
})
}

View File

@@ -11,7 +11,10 @@ export default async function volume(interaction: ChatInputCommandInteraction) {
if (!queue) {
await interaction.editReply({
content: "There is no queue"
embeds: [{
description: "There is no music playing",
color: embedColor
}]
})
return
}