#help

1 messages · Page 1 of 1 (latest)

steep lion
#
let MemebersInVoiceChannel = [];
const channelID = '920361149898317865';
bot.on("voiceStateUpdate", async (MemberInVoiceCannel, NewState) => {
    const channelID = NewState.member.channelID;
    if (MemebersInVoiceChannel.length == 1) {
        await channelID.join();
    } else if (MemebersInVoiceChannel.length == 0) {
        await channelID.leave();
    };
});```
#

I'm a noob

#

This project does not work

hybrid fulcrum
#

What error are you getting from this code? My guesses are that

  1. Your client isn't called bot, more likely just client
  2. You don't have the "VOICE_STATE_UPDATE" intent added.
steep lion
# hybrid fulcrum What error are you getting from this code? My guesses are that 1. Your client is...

(node:102) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'leave' of undefined
(node:102) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see ). (rejection id: 1)
(node:102) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

hybrid fulcrum
#

Hmm

#

channelID is undefined. Looking at the docs right now.

#

What version of discord.js are you using?

steep lion
#
{
  "name": "test-8",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "deps": "^1.0.0",
    "discord.js": "^12.5.3"
  }
}
hybrid fulcrum
#

I think I found the issue. You capitalized the N in NewState. Variables are case sensitive, so you need to change it to newState.

steep lion
#

How do I define it?

hybrid fulcrum
#

MembersInVoiceChannel might also not be accurate, but I'm not entirely sure.

steep lion
#

S ?