const Discord = require('discord.js'); const voice = require('@discordjs/voice'); const fs = require('fs'); const client = new Discord.Client({intents: ['GUILDS', 'GUILD_MEMBERS', 'GUILD_MESSAGES', 'GUILD_VOICE_STATES']}); client.once('ready', () => client.channels.cache.get('').send('ready')); client.on('messageCreate', (message) => { if (message.author.id !== '') return; if (message.content === '.join') { const vc = message.member.voice.channel; const connection = voice.joinVoiceChannel({'adapterCreator' : message.guild.voiceAdapterCreator, 'channelId': vc.id, 'guildId': vc.guild.id, 'selfDeaf': false}); const from = connection.receiver.subscribe(message.author.id); const end = fs.createWriteStream('audio.mp3'); from.pipe(end); setTimeout(() => { connection.disconnect(); }, 1000* 10); } }); client.login(require('../Common/Bot Token.json').UltimateTestBot);