Make sure a presence update payload is valid

This commit is contained in:
SeanOMik 2020-08-30 22:41:22 -05:00
parent 2ff89d9e18
commit 611ac34389
No known key found for this signature in database
GPG Key ID: FA4D55AC05268A88
1 changed files with 12 additions and 11 deletions

View File

@ -410,6 +410,7 @@ proc messageReactionRemoveEmoji(shard: Shard, json: JsonNode) =
proc presenceUpdate(shard: Shard, json: JsonNode) = proc presenceUpdate(shard: Shard, json: JsonNode) =
# This proc doesn't actually dispatch any events, # This proc doesn't actually dispatch any events,
# it just updates member.presence # it just updates member.presence
if json.contains("guild_id"): # Make sure that json contains a guild_id
var g = shard.client.cache.getGuild(getIDFromJson(json["guild_id"].getStr())) var g = shard.client.cache.getGuild(getIDFromJson(json["guild_id"].getStr()))
var member = g.getGuildMember(getIDFromJson(json["user"]["id"].getStr())) var member = g.getGuildMember(getIDFromJson(json["user"]["id"].getStr()))