Compare commits
No commits in common. "74cac2bfbbf3cfd7f64f7262e9537100f974c7f0" and "0d0125bf5594b393db05992a2e7ac9219148f660" have entirely different histories.
74cac2bfbb
...
0d0125bf55
@ -11,13 +11,6 @@ services:
|
|||||||
- LAVALINK_SERVER_PASSWORD=${LAVALINK_PASSWORD}
|
- LAVALINK_SERVER_PASSWORD=${LAVALINK_PASSWORD}
|
||||||
volumes:
|
volumes:
|
||||||
- ./application.yml:/opt/Lavalink/application.yml:ro,Z
|
- ./application.yml:/opt/Lavalink/application.yml:ro,Z
|
||||||
# Add healthcheck to verify Lavalink is ready
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:2333/v4/info"]
|
|
||||||
interval: 10s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 5
|
|
||||||
start_period: 15s # Give Lavalink time to start up initially
|
|
||||||
|
|
||||||
bot:
|
bot:
|
||||||
build: .
|
build: .
|
||||||
@ -31,10 +24,8 @@ services:
|
|||||||
- LAVALINK_HOST=lavalink
|
- LAVALINK_HOST=lavalink
|
||||||
- LAVALINK_PORT=2333
|
- LAVALINK_PORT=2333
|
||||||
- LAVALINK_PASSWORD=${LAVALINK_PASSWORD}
|
- LAVALINK_PASSWORD=${LAVALINK_PASSWORD}
|
||||||
# Update depends_on to wait for healthcheck
|
|
||||||
depends_on:
|
depends_on:
|
||||||
lavalink:
|
- lavalink
|
||||||
condition: service_healthy
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
bot-network:
|
bot-network:
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
const { SlashCommandBuilder, MessageFlags } = require('discord.js'); // Import MessageFlags
|
const { SlashCommandBuilder } = require('discord.js');
|
||||||
const logger = require('../utils/logger');
|
const logger = require('../utils/logger');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@ -6,20 +6,11 @@ module.exports = {
|
|||||||
.setName('leave')
|
.setName('leave')
|
||||||
.setDescription('Leaves the current voice channel'),
|
.setDescription('Leaves the current voice channel'),
|
||||||
async execute(interaction, client) { // Added client parameter
|
async execute(interaction, client) { // Added client parameter
|
||||||
// Use flags for ephemeral deferral
|
await interaction.deferReply({ ephemeral: true });
|
||||||
await interaction.deferReply({ flags: MessageFlags.Ephemeral });
|
|
||||||
|
|
||||||
// Get the Shoukaku player manager
|
const player = client.manager.get(interaction.guildId);
|
||||||
const musicPlayer = interaction.client.player;
|
|
||||||
if (!musicPlayer) {
|
|
||||||
logger.error('Music player not initialized on client object!');
|
|
||||||
return interaction.editReply('The music player is not ready yet.');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the player for this guild using Shoukaku manager
|
// Check if the player exists and the bot is in a voice channel
|
||||||
const player = musicPlayer.getPlayer(interaction.guildId);
|
|
||||||
|
|
||||||
// Check if the player exists (Shoukaku player object has voiceChannel property)
|
|
||||||
if (!player || !player.voiceChannel) {
|
if (!player || !player.voiceChannel) {
|
||||||
return interaction.editReply('I am not currently in a voice channel!');
|
return interaction.editReply('I am not currently in a voice channel!');
|
||||||
}
|
}
|
||||||
@ -31,11 +22,11 @@ module.exports = {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const channelId = player.voiceChannel; // Get channel ID from Shoukaku player
|
const channelId = player.voiceChannel;
|
||||||
const channel = client.channels.cache.get(channelId);
|
const channel = client.channels.cache.get(channelId);
|
||||||
const channelName = channel ? channel.name : `ID: ${channelId}`; // Get channel name if possible
|
const channelName = channel ? channel.name : `ID: ${channelId}`; // Get channel name if possible
|
||||||
|
|
||||||
player.destroy(); // Use Shoukaku player's destroy method
|
player.destroy(); // Disconnects, clears queue, and destroys the player instance
|
||||||
logger.info(`Player destroyed and left voice channel ${channelName} in guild ${interaction.guild.name} (${interaction.guildId}) by user ${interaction.user.tag}`);
|
logger.info(`Player destroyed and left voice channel ${channelName} in guild ${interaction.guild.name} (${interaction.guildId}) by user ${interaction.user.tag}`);
|
||||||
await interaction.editReply(`Left ${channelName}.`);
|
await interaction.editReply(`Left ${channelName}.`);
|
||||||
|
|
||||||
|
|||||||
@ -212,22 +212,19 @@ class MusicPlayer {
|
|||||||
if (!node) throw new Error('No available Lavalink nodes!');
|
if (!node) throw new Error('No available Lavalink nodes!');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Determine search type and prepare the identifier string
|
// Determine search type
|
||||||
let identifier;
|
let searchOptions = {};
|
||||||
if (query.startsWith('http')) {
|
if (query.startsWith('http')) {
|
||||||
// Direct URL
|
// Direct URL
|
||||||
identifier = query;
|
searchOptions = { query };
|
||||||
} else {
|
} else {
|
||||||
// Search with prefix (Lavalink handles ytsearch/ytmsearch automatically with the plugin)
|
// Search with prefix
|
||||||
// identifier = `ytsearch:${query}`; // Prefix might not be needed with the plugin, let Lavalink decide
|
searchOptions = { query: `ytsearch:${query}` };
|
||||||
identifier = query; // Pass the raw query for non-URLs
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform the search using the identifier string
|
// Perform the search
|
||||||
const result = await node.rest.resolve(identifier);
|
const result = await node.rest.resolve(searchOptions);
|
||||||
if (!result || result.loadType === 'error' || result.loadType === 'empty') {
|
if (!result || result.loadType === 'error' || result.loadType === 'empty') {
|
||||||
// Log the identifier for debugging if search fails
|
|
||||||
logger.debug(`Search failed for identifier: ${identifier}`);
|
|
||||||
throw new Error(result?.exception?.message || 'No results found');
|
throw new Error(result?.exception?.message || 'No results found');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user