@@ -2331,7 +2331,7 @@ namespace Discord.WebSocket | |||||
SocketUser user = data.User.IsSpecified | SocketUser user = data.User.IsSpecified | ||||
? State.GetOrAddUser(data.User.Value.Id, (_) => SocketGlobalUser.Create(this, State, data.User.Value)) | ? 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; | SocketChannel channel = null; | ||||
if(data.ChannelId.IsSpecified) | if(data.ChannelId.IsSpecified) | ||||
@@ -2346,8 +2346,12 @@ namespace Discord.WebSocket | |||||
} | } | ||||
else | 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. | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -19,13 +19,14 @@ namespace Discord.WebSocket | |||||
/// Gets the <see cref="ISocketMessageChannel"/> this interaction was used in. | /// Gets the <see cref="ISocketMessageChannel"/> this interaction was used in. | ||||
/// </summary> | /// </summary> | ||||
/// <remarks> | /// <remarks> | ||||
/// If the channel isn't cached or the bot doesn't have access to it then | |||||
/// If the channel isn't cached, the bot scope isn't used, or the bot doesn't have access to it then | |||||
/// this property will be <see langword="null"/>. | /// this property will be <see langword="null"/>. | ||||
/// </remarks> | /// </remarks> | ||||
public ISocketMessageChannel Channel { get; private set; } | public ISocketMessageChannel Channel { get; private set; } | ||||
/// <summary> | /// <summary> | ||||
/// Gets the <see cref="SocketUser"/> who triggered this interaction. | /// Gets the <see cref="SocketUser"/> who triggered this interaction. | ||||
/// This property will be <see langword="null"/> if the bot scope isn't used. | |||||
/// </summary> | /// </summary> | ||||
public SocketUser User { get; private set; } | public SocketUser User { get; private set; } | ||||