Fix nullref exceptions from Rich Presences

This commit is contained in:
Christopher F
2018-01-05 20:49:59 -05:00
parent 227f61aa4e
commit c08f37bb03

View File

@@ -17,9 +17,9 @@
State = model.State.GetValueOrDefault(),
SmallAsset = assets?[0],
LargeAsset = assets?[1],
Party = model.Party.GetValueOrDefault()?.ToEntity(),
Secrets = model.Secrets.GetValueOrDefault()?.ToEntity(),
Timestamps = model.Timestamps.GetValueOrDefault()?.ToEntity()
Party = model.Party.IsSpecified ? model.Party.Value.ToEntity() : null,
Secrets = model.Secrets.IsSpecified ? model.Secrets.Value.ToEntity() : null,
Timestamps = model.Timestamps.IsSpecified ? model.Timestamps.Value.ToEntity() : null
};
}
// Stream Game
@@ -56,11 +56,9 @@
public static GameParty ToEntity(this API.GameParty model)
{
// todo: proper fix for this
if (model == null) return null;
// Discord will probably send bad data since they don't validate anything
int current = 0, cap = 0;
if (model.Size.Length == 2)
if (model.Size?.Length == 2)
{
current = model.Size[0];
cap = model.Size[1];