Why is there no musik?

What's wrong? I am using discord.js 14.7.1
4 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Serial Designation N
const { SlashCommandBuilder } = require('@discordjs/builders');
const { joinVoiceChannel, createAudioPlayer, createAudioResource } = require('@discordjs/voice');
const { ChannelType } = require('discord.js');
const path = require('path');

module.exports = {
data: new SlashCommandBuilder()
.setName('play')
.setDescription('Spielt eine MP3-Datei ab.')
.addChannelOption((option) => option.setName('channel').setDescription('Voicechannel').setRequired(true).addChannelTypes(ChannelType.GuildVoice)),
async execute(interaction) {
try {
const vchannel = interaction.options.getChannel('channel');
const connection = joinVoiceChannel({
channelId: vchannel.id,
guildId: interaction.guildId,
adapterCreator: interaction.guild.voiceAdapterCreator,
});
const player = createAudioPlayer();
const resource = createAudioResource(path.join(__dirname, 'Final.mp3'));

await player.play(resource);
connection.subscribe(player);

await interaction.reply('Musik wird abgespielt.');
} catch (error) {
console.error(error);
await interaction.reply('Es gab einen Fehler beim Abspielen der Musik.');
}
},
};
const { SlashCommandBuilder } = require('@discordjs/builders');
const { joinVoiceChannel, createAudioPlayer, createAudioResource } = require('@discordjs/voice');
const { ChannelType } = require('discord.js');
const path = require('path');

module.exports = {
data: new SlashCommandBuilder()
.setName('play')
.setDescription('Spielt eine MP3-Datei ab.')
.addChannelOption((option) => option.setName('channel').setDescription('Voicechannel').setRequired(true).addChannelTypes(ChannelType.GuildVoice)),
async execute(interaction) {
try {
const vchannel = interaction.options.getChannel('channel');
const connection = joinVoiceChannel({
channelId: vchannel.id,
guildId: interaction.guildId,
adapterCreator: interaction.guild.voiceAdapterCreator,
});
const player = createAudioPlayer();
const resource = createAudioResource(path.join(__dirname, 'Final.mp3'));

await player.play(resource);
connection.subscribe(player);

await interaction.reply('Musik wird abgespielt.');
} catch (error) {
console.error(error);
await interaction.reply('Es gab einen Fehler beim Abspielen der Musik.');
}
},
};
ShompiFlen
ShompiFlen2y ago
player.play() is not awaitable you might be missing the GuildVoiceStates intent making your bot get stuck in the signalling status make sure the Final.mp3 file is on the same folder as the script make sure your firewall is not blocking udp ports
Serial Designation N
I cannot hear any musik when his in- and output is deactivated, can I?
Want results from more Discord servers?
Add your server