Fix gateway interactions not running without bot scope. (#2217)

* Init

* Implement public channelId
This commit is contained in:
Armano den Boef
2022-04-04 23:16:13 +02:00
committed by GitHub
parent a744948477
commit 8522447c27
2 changed files with 23 additions and 9 deletions

View File

@@ -2331,7 +2331,7 @@ namespace Discord.WebSocket
SocketUser user = data.User.IsSpecified
? State.GetOrAddUser(data.User.Value.Id, (_) => SocketGlobalUser.Create(this, State, data.User.Value))
: guild.AddOrUpdateUser(data.Member.Value);
: guild?.AddOrUpdateUser(data.Member.Value); // null if the bot scope isn't set, so the guild cannot be retrieved.
SocketChannel channel = null;
if(data.ChannelId.IsSpecified)
@@ -2346,8 +2346,12 @@ namespace Discord.WebSocket
}
else
{
await UnknownChannelAsync(type, data.ChannelId.Value).ConfigureAwait(false);
return;
if (guild != null) // The guild id is set, but the guild cannot be found as the bot scope is not set.
{
await UnknownChannelAsync(type, data.ChannelId.Value).ConfigureAwait(false);
return;
}
// The channel isnt required when responding to an interaction, so we can leave the channel null.
}
}
}