i so i need a muisc slash command and i need it to wrck i can give my code but it dos not wrck
if you can fix pls tell me code const { SlashCommandBuilder } = require('@discordjs/builders');
const { joinVoiceChannel, createAudioPlayer, createAudioResource, AudioPlayerStatus } = require('@discordjs/voice');
const ytdl = require('ytdl-core');
const command = {
data: new SlashCommandBuilder()
.setName('joinvc')
.setDescription('Joins a voice channel and plays Rick Astley - Never Gonna Give You Up'),
async execute(interaction) {
const voiceChannel = interaction.member.voice.channel;
if (!voiceChannel) {
return interaction.reply('You need to be in a voice channel to use this command!');
}
const connection = joinVoiceChannel({
channelId: voiceChannel.id,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
});
const player = createAudioPlayer();
const stream = ytdl('https://www.youtube.com/watch?v=dQw4w9WgXcQ', { filter: 'audioonly' });
const resource = createAudioResource(stream);
player.play(resource);
connection.subscribe(player);
player.on(AudioPlayerStatus.Playing, () => {
interaction.reply('Now playing: Rick Astley - Never Gonna Give You Up');
});
player.on('error', error => {
console.error(
Error: ${error.message}
);
});
}
};
module.exports = command;Rick Astley
YouTube
Rick Astley - Never Gonna Give You Up (Official Music Video)
The official video for “Never Gonna Give You Up” by Rick Astley.
The new album 'Are We There Yet?' is out now: Download here: https://RickAstley.lnk.to/AreWeThereYetFA/itunes
“Never Gonna Give You Up” was a global smash on its release in July 1987, topping the charts in 25 countries including Rick’s native UK and the US Billboard Hot 100. It...
5 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!there wasn't really a need to create a new post
just explaining in your already existing post was fine
that being said, streaming from youtube to discord is explicitly against youtube's tos, and by extension, discord's tos
we do not support tos violations
how do i fix the code to wrck on a difit patforme
idk waht a goood on
o god
const { SlashCommandBuilder } = require('@discordjs/builders');
const { joinVoiceChannel, createAudioPlayer, NoSubscriberBehavior, AudioPlayerStatus, VoiceConnectionStatus } = require('@discordjs/voice');
const { LavalinkClient } = require('lavalink');
const command = {
data: new SlashCommandBuilder()
.setName('music')
.setDescription('Plays a song using Lavalink'),
async execute(interaction, client) {
const voiceChannel = interaction.member.voice.channel;
if (!voiceChannel) {
return interaction.reply('You need to be in a voice channel to use this command!');
}
const player = createAudioPlayer({ behaviors: { noSubscriber: NoSubscriberBehavior.Pause } });
const connection = joinVoiceChannel({
channelId: voiceChannel.id,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
});
connection.subscribe(player);
const lavalinkClient = new LavalinkClient(client, [{ name: 'main', url: 'lava1.horizxon.tech', port: '443', password: 'horizxon.tech', secure: true }]);
await lavalinkClient.connect();
const track = await lavalinkClient.loadTracks('rick rool');
if (track) {
player.play(track);
interaction.reply('Now playing: Rick Astley - Never Gonna Give You Up');
} else {
interaction.reply('Could not find the track.');
}
player.on(AudioPlayerStatus.Playing, () => {
console.log('The audio is now playing!');
});
player.on('error', error => {
console.error(
Error: ${error.message}
);
});
}
};
module.exports = command;
pls fix
@Qjuh
ugwhy are u sharing your password if thats a valid one please change it
It looks like you did just share your lavalink login info, might want to edit that out of your messages