const { ErelaClient, SpotifyPlugin, DeezerPlugin } = require('erela.js-custom-1.1.8');
const { Client } = require('discord.js');
const client = new Client({ intents: 32767 });
client.login('TOKEN DISCORD');
client.on('ready', () => {
console.log(client.user.tag);
client.music = new ErelaClient(client, [{ host: "HOST NAME", port: 0000, password: "PASSWORD" }],
{
sources: {
default: "soundcloud", //Source par default à utiliser (soundcloud ou youtube)
spotify: "soundcloud", //Source a utiliser pour la recherche Spotify'Url (soundcloud ou youtube)
deezer: "soundcloud" //Source a utiliser pour la recherche Deezer'Url (soundcloud ou youtube)
},
plugins: [
new SpotifyPlugin({
clientID: "ClientID", //Identifiant récupérable sur le Dashboard des développeurs Spotify
clientSecret: "ClientSecret" //Identifiant secret récupérable sur le Dashboard des développeurs spotify
}),
new DeezerPlugin()
]
});
});
client.on('messageCreate', async message => {
if(message.content.startsWith("!p")) { //"!p Risk Astley"
const musicSearch = message.content.slice(3);
const tracks = await client.music.search({
source: "soundcloud",
query: musicSearch
}, message.author);
const musicPlayer = client.music.players.spawn({
guild: message.guild,
voiceChannel: message.member.voice.channel,
textChannel: message.channel,
});
musicPlayer.queue.add(tracks.tracks[0]);
musicPlayer.play();
return message.channel.send(`${tracks.tracks[0].title} lancée !`);
};
});