yt audio player aborted
what is happening here?
const { SlashCommandBuilder } = require('@discordjs/builders');
const { VoiceConnection, createAudioResource, StreamType, joinVoiceChannel, createAudioPlayer } = require('@discordjs/voice');
const { ChannelType } = require('discord.js');
const ytdl = require('ytdl-core-discord');
module.exports = {
data: new SlashCommandBuilder()
.setName('play-yt')
.setDescription('Spielt einen YouTube-Link in einem Voice-Channel ab.')
.addStringOption(option =>
option.setName('url')
.setDescription('Der YouTube-Link, der abgespielt werden soll.')
.setRequired(true))
.addChannelOption((option) => option.setName('channel').setDescription('Voicechannel').setRequired(true).addChannelTypes(ChannelType.GuildVoice)),
async execute(interaction) {
const url = interaction.options.getString('url');
const voiceChannel = interaction.member.voice.channel;
if (!voiceChannel) {
return interaction.reply('error');
}
try {
const vchannel = interaction.options.getChannel('channel');
const vconnection = joinVoiceChannel({
channelId: vchannel.id,
guildId: interaction.guildId,
adapterCreator: interaction.guild.voiceAdapterCreator,
selfDeaf: true,
selfMute: false
});
const stream = await ytdl(url, { filter: 'audioonly', quality: 'highestaudio' });
const vplayer = createAudioPlayer();
const vresource = createAudioResource(stream, { inputType: StreamType.Opus });
vplayer.play(vresource);
vconnection.subscribe(vplayer);
await interaction.reply(`Spiele \`${url}\` ab.`);
} catch (error) {
console.error(error);
interaction.reply('error');
}
},
};
const { SlashCommandBuilder } = require('@discordjs/builders');
const { VoiceConnection, createAudioResource, StreamType, joinVoiceChannel, createAudioPlayer } = require('@discordjs/voice');
const { ChannelType } = require('discord.js');
const ytdl = require('ytdl-core-discord');
module.exports = {
data: new SlashCommandBuilder()
.setName('play-yt')
.setDescription('Spielt einen YouTube-Link in einem Voice-Channel ab.')
.addStringOption(option =>
option.setName('url')
.setDescription('Der YouTube-Link, der abgespielt werden soll.')
.setRequired(true))
.addChannelOption((option) => option.setName('channel').setDescription('Voicechannel').setRequired(true).addChannelTypes(ChannelType.GuildVoice)),
async execute(interaction) {
const url = interaction.options.getString('url');
const voiceChannel = interaction.member.voice.channel;
if (!voiceChannel) {
return interaction.reply('error');
}
try {
const vchannel = interaction.options.getChannel('channel');
const vconnection = joinVoiceChannel({
channelId: vchannel.id,
guildId: interaction.guildId,
adapterCreator: interaction.guild.voiceAdapterCreator,
selfDeaf: true,
selfMute: false
});
const stream = await ytdl(url, { filter: 'audioonly', quality: 'highestaudio' });
const vplayer = createAudioPlayer();
const vresource = createAudioResource(stream, { inputType: StreamType.Opus });
vplayer.play(vresource);
vconnection.subscribe(vplayer);
await interaction.reply(`Spiele \`${url}\` ab.`);
} catch (error) {
console.error(error);
interaction.reply('error');
}
},
};
4 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
error:
what do you mean?
uff i haven't known this
now you know