const Discord = require('discord.js');
const ytdl = require('ytdl-core');
const client = new Discord.Client({
intents: [
Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.GuildMessages,
Discord.GatewayIntentBits.MessageContent
]
})
const token = 'MTA1NDUwMTA1NTI1OTQ4MDEzNg.GGOpkG.xRaiMaqm5n7Ma6Y01blmlOksAGqpZmVbwr50c8';
const prefix = '!'; // prefix dla poleceń bota
client.on('ready', () => {
console.log('Bot jest gotowy do działania!');
});
client.on('messageCreate', async message => {
if (!message.content.startsWith(prefix) || message.author.bot) return; // ignorowanie poleceń od innych botów i poleceń bez prefixa
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if (command === 'play') {
const voiceChannel = message.member.voice.channel;
if (!voiceChannel) return message.reply('Nie jesteś podłączony do kanału głosowego!');
const permissions = voiceChannel.permissionsFor(message.client.user);
if (!permissions.has('Connect') || !permissions.has('Speak')) {
return message.reply('Nie posiadam odpowiednich uprawnień, aby połączyć się i rozmawiać na kanale głosowym!');
}
if (!args.length) return message.reply('Nie podałeś linku do muzyki!');
const connection = await voiceChannel.join();
const stream = ytdl(args[0], { filter: 'audioonly' });
const dispatcher = connection.play(stream);
dispatcher.on('finish', () => voiceChannel.leave());
} else if (command === 'stop') {
const voiceChannel = message.member.voice.channel;
if (!voiceChannel) return message.reply('Nie jesteś podłączony do kanału głosowego!');
voiceChannel.leave();
}
});
client.login(token);
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}