Closed reecebenson closed 7 years ago
The event fires before actually updating the member in the guild member cache. The output you posted earlier is as expected. In the first scenario, the guild member joins a voice channel; thus the old member has no voice channel ID. The second scenario also makes sense; the member is switching from channel to channel. I have no idea why in your code you're fetching the guild member from the cache when you already have access to the guild member object.
You state that in the first scenario, the guild member joins the channel thus the old member having no voice channel ID
but I'm clearly stating that I am not using the old member variable at all. The <NewMember>
variable should hold the members current and correct voice channel ID whereas <OldMember>
should hold the previous values.
Joining a Voice Channel:
<OldMember>.voiceChannelID; // undefined (expected)
<NewMember>.voiceChannelID; // undefined (previous & incorrect)
<NewMember>.guild.members.get(<NewMember>.id).voiceChannel.id; // 12345 (current & correct)
However both variables old and new remain undefined until the next voice state update - and those values are then outdated.
Hey. I just tested this on latest master (Actual Commit hash 97823bc3761bea0bfba34fc2f8b85765084d9d0d) and it seems to work as intended. Try updating Discord.js and see if you can still reproduce it
Can confirm on latest commit, values work as intended. Thank you @KingDGrizzle :)
Please describe the problem you are having in as much detail as possible: When moving users from channel to channel and omitting the
voiceStateUpdate
event, the<NewMember>
variable doesn't actually grab the latest voiceChannelID of the user.To demonstrate this a little further, imagine I have two voice channels:
ID: 12345
ID: 67890
I have my bot (or a user) join the voice channel Music. The log would be shown like so (in accordance to the reproducible code sample below):
As you can see by the log, the
newMbr
variable doesn't have a voice channel set whereas theguildMbr
variable does. When moving the joined user from Music to General, the log shows like so:Include a reproducible code sample here, if possible:
Workaround (temporary fix)
Further details:
ec4c98704fc706e416683d6bd950de6b7c0614da
voiceStateUpdate.js file