Slash command not working for play (embed sending) #309
-
if /play song name/url bot join and playing a song but not send embederror:
index.jsclient.distube.on('playSong', (queue, song) => {
const embed = new EmbedBuilder()
.setTitle("HafeX | Music system")
.setImage("https://hafex.xyz/hafex_banner.png")
.setColor('#0095FF')
.setDescription(`# ${song.name}\n> **Duration:** \`${song.formattedDuration}\`\n> **Requested by:** ${song.user}`)
.setFooter({ text: 'HafeX Bot', iconURL: 'https://hafex.xyz/hafex.png' });
queue.textChannel.send({ embeds: [embed] });
});
// Your existing code for 'addSong' event listener
client.distube.on('addSong', (queue, song) => {
const embed = new EmbedBuilder()
.setTitle("HafeX | Music system")
.setImage("https://hafex.xyz/hafex_banner.png")
.setColor('#0095FF')
.setDescription(`Test`)
.setFooter({ text: 'HafeX Bot', iconURL: 'https://hafex.xyz/hafex.png' });
queue.textChannel.send(embed);
});
// Your existing code for 'addList' event listener
client.distube.on('addList', (queue, playlist) => {
const embed = new EmbedBuilder()
.setTitle("HafeX | Music system")
.setImage("https://hafex.xyz/hafex_banner.png")
.setColor('#0095FF')
.setDescription(`# ${playlist.name}\n> **Playlist:** \`${playlist.songs.length}\``)
.setFooter({ text: 'HafeX Bot', iconURL: 'https://hafex.xyz/hafex.png' });
queue.textChannel.send({ embeds: [embed] });
});
client.distube.on('error', (channel, e) => {
if (channel) {
const embed = new EmbedBuilder()
.setTitle("HafeX | Music system")
.setImage("https://hafex.xyz/hafex_banner.png")
.setColor('#0095FF')
.setDescription(`<:no:1128728706777616486> | An error encountered: ${e.toString().slice(0, 1974)}`)
.setFooter({ text: 'HafeX Bot', iconURL: 'https://hafex.xyz/hafex.png' });
queue.textChannel.send({ embeds: [embed] });
} else {
console.error(e);
}
})
client.distube.on('empty', (queue, channel) => {
const embed = new EmbedBuilder()
.setTitle("HafeX | Music system")
.setImage("https://hafex.xyz/hafex_banner.png")
.setColor('#0095FF')
.setDescription(`<:no:1128728706777616486> | Voice channel is empty! Leaving the channel...`)
.setFooter({ text: 'HafeX Bot', iconURL: 'https://hafex.xyz/hafex.png' });
queue.textChannel.send({ embeds: [embed] });
})
client.distube.on('searchNoResult', (interaction, query) => {
const embed = new EmbedBuilder()
.setTitle("HafeX | Music system")
.setImage("https://hafex.xyz/hafex_banner.png")
.setColor('#0095FF')
.setDescription(`<:no:1128728706777616486> | No result found for \`${query}\`!`)
.setFooter({ text: 'HafeX Bot', iconURL: 'https://hafex.xyz/hafex.png' });
queue.textChannel.send({ embeds: [embed] });
})
client.distube.on('finish', queue => {
const embed = new EmbedBuilder()
.setTitle("HafeX | Music system")
.setImage("https://hafex.xyz/hafex_banner.png")
.setColor('#0095FF')
.setDescription(`The song was finished`)
.setFooter({ text: 'HafeX Bot', iconURL: 'https://hafex.xyz/hafex.png' });
queue.textChannel.send({ embeds: [embed] });
}); empty, searchNoResult, Finish, error working | playSong and addSong and addList not workingplay.jsconst { SlashCommandBuilder } = require('discord.js');
const mysql = require('mysql2');
const config = require('../../config.json');
const { EmbedBuilder } = require('discord.js');
const { QueryType } = require('discord-player');
const connection = mysql.createConnection({
host: config.db_hostitel,
port: config.db_port,
user: config.db_uzivatel,
password: config.db_heslo,
database: config.db_databaze,
});
module.exports = {
name: 'play',
description: '[Youtube URL / Youtube name / Spotify URL / SoundCloud URL]',
data: new SlashCommandBuilder()
.setName('play')
.setDescription('Play a song')
.addStringOption(option =>
option
.setName('song')
.setDescription('Youtube URL / Youtube name / Spotify URL / SoundCloud URL')
.setRequired(true)),
async execute(interaction, client) {
const embed = new EmbedBuilder()
.setColor('#0095FF')
.setTitle('HafeX | Music system')
.setImage('https://hafex.xyz/hafex_banner.png')
.setFooter({ text: 'HafeX Bot', iconURL: 'https://hafex.xyz/hafex.png' });
const voiceChannel = interaction.member.voice.channel;
if (!voiceChannel) {
embed.setDescription('<:no:1128728706777616486> You must be connected to a voice channel.');
return interaction.reply({ embeds: [embed] });
}
const guildId = interaction.guild.id;
connection.query('SELECT music_enabled FROM bot_features_guild WHERE guild_id = ?', [guildId], (err, results) => {
if (err) {
console.error(err);
embed.setDescription('<:no:1128728706777616486> An error occurred while querying the database.');
return interaction.reply({ embeds: [embed] });
}
if (results.length === 0 || results[0].music_enabled !== 'Yes') {
embed.setDescription('<:no:1128728706777616486> You do not have the music system enabled. Please enable it in the dashboard/manage server/features -> https://hafex.xyz/.');
return interaction.reply({ embeds: [embed] });
}
const song = interaction.options.getString('song');
if (song.includes('youtube.com/playlist')) {
client.distube.playlist(voiceChannel, song, {
textChannel: interaction.channel,
member: interaction.member,
interaction,
});
} else {
client.distube.play(voiceChannel, song, {
textChannel: interaction.channel,
member: interaction.member,
interaction,
metadata: interaction ,
}).catch(error => {
console.error(error);
embed.setDescription('<:no:1128728706777616486> An error occurred during song playback.');
return interaction.reply({ embeds: [embed] });
});
}
});
},
}; |
Beta Was this translation helpful? Give feedback.
Answered by
skick1234
Aug 6, 2023
Replies: 1 comment
-
Anyway, it is not related to distube so I will close this here. You should ask in discord.js server for any |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
skick1234
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Anyway, it is not related to distube so I will close this here. You should ask in discord.js server for any
DiscordAPIErrror
queétion