fix(Resolvables): valid resolvables throw error when uncached (#5495)

Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com>
This commit is contained in:
Shubham Parihar
2021-04-15 04:02:08 +05:30
committed by GitHub
parent b380f16367
commit fa5a37e51a
5 changed files with 21 additions and 20 deletions

View File

@@ -285,11 +285,12 @@ class GuildMember extends Base {
*/
async edit(data, reason) {
if (data.channel) {
data.channel = this.guild.channels.resolve(data.channel);
if (!data.channel || data.channel.type !== 'voice') {
const voiceChannelID = this.guild.channels.resolveID(data.channel);
const voiceChannel = this.guild.channels.cache.get(voiceChannelID);
if (!voiceChannelID || (voiceChannel && voiceChannel?.type !== 'voice')) {
throw new Error('GUILD_VOICE_CHANNEL_RESOLVE');
}
data.channel_id = data.channel.id;
data.channel_id = voiceChannelID;
data.channel = undefined;
} else if (data.channel === null) {
data.channel_id = null;