- and this is what I got in `console.log('msg2', msg)`;
<img width="358" alt="스크린샷 2024-02-25 오후 10 12 14" src="https://github.com/Rei-x/discord-speech-recognition/assets/70994795/4b4fa734-6970-45f6-b69d-483836f83d64">
- this is dependencies in package.json
question : I cannot access
msg.member?.voice.channel
this is my codes
const fs = require('node:fs'); const path = require('node:path'); require('dotenv').config();
const token = process.env.DISCORD_TOKEN;
const client = new Client({ intents: [ GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildMessages, GatewayIntentBits.Guilds, GatewayIntentBits.MessageContent, ], });
addSpeechEvent(client);
client.on(Events.MessageCreate, (msg) => { console.log('msg2', msg);
const voiceChannel = msg.member?.voice.channel;
// if (voiceChannel) { // joinVoiceChannel({ // channelId: voiceChannel.id, // guildId: voiceChannel.guild.id, // adapterCreator: voiceChannel.guild.voiceAdapterCreator, // selfDeaf: false, // }); // } });
client.on(SpeechEvents.speech, (msg) => { // If bot didn't recognize speech, content will be empty if (!msg.content) return;
msg.author.send(msg.content); });
const eventsPath = path.join(__dirname, 'events'); const eventFiles = fs.readdirSync(eventsPath).filter((file) => file.endsWith('.js'));
for (const file of eventFiles) { const filePath = path.join(eventsPath, file); const event = require(filePath); if (event.once) { client.once(event.name, (...args) => event.execute(...args)); } else { client.on(event.name, (...args) => event.execute(...args)); } }
client.login(token);
"dependencies": { "@discordjs/opus": "github:discordjs/opus", "discord-speech-recognition": "^3.4.1", "discord.js": "^14.14.1", "dotenv": "^16.4.5", "sodium": "^3.0.2" },