Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { Client, GatewayIntentBits } = require('discord.js');
- const { MoonlinkManager } = require('moonlink.js');
- const { joinVoiceChannel } = require('@discordjs/voice');
- const yts = require('yt-search');
- const _c = new Client({ intents: [
- GatewayIntentBits.Guilds,
- GatewayIntentBits.GuildVoiceStates,
- GatewayIntentBits.GuildMessages,
- GatewayIntentBits.MessageContent
- ] });
- const _n = [{
- host: '',
- port: ,
- secure: ,
- password: ''
- }];
- const _m = new MoonlinkManager(_n, {}, (g, p) => {
- _c.guilds.cache.get(g)?.shard.send(JSON.parse(p));
- });
- _c.once('ready', () => {
- _m.init(_c.user.id);
- console.log('bot has ready on djs');
- });
- _c.ws.on('VOICE_SERVER_UPDATE', d => _m.packetUpdate(d));
- _c.ws.on('VOICE_STATE_UPDATE', d => _m.packetUpdate(d));
- _c.on('messageCreate', async m => {
- if (!m.content.startsWith('-') || m.author.bot) return;
- const [_cmd, ..._a] = m.content.slice(1).trim().split(/ +/g);
- const _vc = m.member.voice.channel;
- const _p = _m.players.get(m.guild.id) || _m.players.create({ guildId: m.guild.id, voiceChannel: _vc.id, textChannel: m.channel.id });
- if (_cmd === 'p') {
- if (!_vc) return m.react('❌');const _q = _a.join(' ');
- const _r = await yts(_q);const _t = _r.videos[0];
- if (!_t) return m.react('❌');if (!_p.connected) joinVoiceChannel({ channelId: _vc.id, guildId: m.guild.id, adapterCreator: m.guild.voiceAdapterCreator });
- _p.play({ track: (await _p.search(_t.url, m.author)).tracks[0] });m.reply("**🎶** :"+_t.title);}
- if (_cmd === 's') {if (!_p || !_p.queue.length) return m.react('❌');_p.skip();m.react(':white_check_mark:');}
- if (_cmd === 'dc') {if (!_p) return m.react('❌');_p.destroy();m.react(':white_check_mark:');}
- if (_cmd === 'np') {if (!_p || !_p.current) return m.react('❌');
- m.reply(`now: **${_p.current.title}**`);
- }
- });
- _c.login('');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement