mirror of
https://github.com/aydenjahola/discord-multipurpose-bot.git
synced 2025-09-21 06:41:35 +01:00
add few more music commands
This commit is contained in:
parent
8c3f955f19
commit
6f25c45e5f
7 changed files with 152 additions and 0 deletions
28
commands/music/nowplaying.js
Normal file
28
commands/music/nowplaying.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("nowplaying")
|
||||
.setDescription("Shows information about the current song"),
|
||||
async execute(interaction, client) {
|
||||
const queue = client.distube.getQueue(interaction.guildId);
|
||||
|
||||
if (!queue || !queue.songs.length) {
|
||||
return interaction.reply("❌ There is no music playing!");
|
||||
}
|
||||
|
||||
const song = queue.songs[0];
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor("#0099ff")
|
||||
.setTitle("🎵 Now Playing")
|
||||
.setDescription(`**${song.name}**`)
|
||||
.addFields(
|
||||
{ name: "Duration", value: song.formattedDuration, inline: true },
|
||||
{ name: "Requested by", value: song.user.toString(), inline: true },
|
||||
{ name: "URL", value: song.url || "No URL available" }
|
||||
)
|
||||
.setThumbnail(song.thumbnail || null);
|
||||
|
||||
interaction.reply({ embeds: [embed] });
|
||||
},
|
||||
};
|
26
commands/music/pause.js
Normal file
26
commands/music/pause.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
const { SlashCommandBuilder } = require("discord.js");
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("pause")
|
||||
.setDescription("Pauses the current song"),
|
||||
async execute(interaction, client) {
|
||||
const queue = client.distube.getQueue(interaction.guildId);
|
||||
|
||||
if (!queue) {
|
||||
return interaction.reply("❌ There is no music playing!");
|
||||
}
|
||||
|
||||
if (queue.paused) {
|
||||
return interaction.reply("⏸️ Music is already paused!");
|
||||
}
|
||||
|
||||
try {
|
||||
await queue.pause();
|
||||
interaction.reply("⏸️ Paused the current song!");
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
interaction.reply("❌ Failed to pause the music.");
|
||||
}
|
||||
},
|
||||
};
|
26
commands/music/resume.js
Normal file
26
commands/music/resume.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
const { SlashCommandBuilder } = require("discord.js");
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("resume")
|
||||
.setDescription("Resumes the paused song"),
|
||||
async execute(interaction, client) {
|
||||
const queue = client.distube.getQueue(interaction.guildId);
|
||||
|
||||
if (!queue) {
|
||||
return interaction.reply("❌ There is no music playing!");
|
||||
}
|
||||
|
||||
if (!queue.paused) {
|
||||
return interaction.reply("▶️ Music is not paused!");
|
||||
}
|
||||
|
||||
try {
|
||||
await queue.resume();
|
||||
interaction.reply("▶️ Resumed the music!");
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
interaction.reply("❌ Failed to resume the music.");
|
||||
}
|
||||
},
|
||||
};
|
22
commands/music/shuffle.js
Normal file
22
commands/music/shuffle.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
const { SlashCommandBuilder } = require("discord.js");
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("shuffle")
|
||||
.setDescription("Shuffles the current queue"),
|
||||
async execute(interaction, client) {
|
||||
const queue = client.distube.getQueue(interaction.guildId);
|
||||
|
||||
if (!queue || queue.songs.length <= 2) {
|
||||
return interaction.reply("❌ Not enough songs in the queue to shuffle!");
|
||||
}
|
||||
|
||||
try {
|
||||
await queue.shuffle();
|
||||
interaction.reply("🔀 Shuffled the queue!");
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
interaction.reply("❌ Failed to shuffle the queue.");
|
||||
}
|
||||
},
|
||||
};
|
31
commands/music/volume.js
Normal file
31
commands/music/volume.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
const { SlashCommandBuilder } = require("discord.js");
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("volume")
|
||||
.setDescription("Adjust the playback volume (1-100)")
|
||||
.addIntegerOption((option) =>
|
||||
option
|
||||
.setName("level")
|
||||
.setDescription("Volume level (1-100)")
|
||||
.setRequired(true)
|
||||
.setMinValue(1)
|
||||
.setMaxValue(100)
|
||||
),
|
||||
async execute(interaction, client) {
|
||||
const volume = interaction.options.getInteger("level");
|
||||
const queue = client.distube.getQueue(interaction.guildId);
|
||||
|
||||
if (!queue) {
|
||||
return interaction.reply("❌ There is no music playing!");
|
||||
}
|
||||
|
||||
try {
|
||||
await queue.setVolume(volume);
|
||||
interaction.reply(`🔊 Volume set to ${volume}%!`);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
interaction.reply("❌ Failed to adjust volume.");
|
||||
}
|
||||
},
|
||||
};
|
7
docker-compose.yml
Normal file
7
docker-compose.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
services:
|
||||
bot:
|
||||
image: ghcr.io/aydenjahola/discord-multipurpose-bot:music
|
||||
container_name: discord-bot
|
||||
restart: unless-stopped
|
||||
env_file: .env
|
12
index.js
12
index.js
|
@ -52,6 +52,18 @@ client.distube
|
|||
})
|
||||
.on("finish", (queue) => {
|
||||
queue.textChannel.send("🎵 Queue finished!");
|
||||
})
|
||||
.on("pause", (queue) => {
|
||||
queue.textChannel.send("⏸️ Music paused!");
|
||||
})
|
||||
.on("resume", (queue) => {
|
||||
queue.textChannel.send("▶️ Music resumed!");
|
||||
})
|
||||
.on("volumeChange", (queue, volume) => {
|
||||
queue.textChannel.send(`🔊 Volume changed to ${volume}%`);
|
||||
})
|
||||
.on("noRelated", (queue) => {
|
||||
queue.textChannel.send("❌ Could not find related video for autoplay!");
|
||||
});
|
||||
|
||||
// Function to recursively read commands from subdirectories
|
||||
|
|
Loading…
Reference in a new issue