Fix nullref exceptions from Rich Presences
This commit is contained in:
@@ -17,9 +17,9 @@
|
|||||||
State = model.State.GetValueOrDefault(),
|
State = model.State.GetValueOrDefault(),
|
||||||
SmallAsset = assets?[0],
|
SmallAsset = assets?[0],
|
||||||
LargeAsset = assets?[1],
|
LargeAsset = assets?[1],
|
||||||
Party = model.Party.GetValueOrDefault()?.ToEntity(),
|
Party = model.Party.IsSpecified ? model.Party.Value.ToEntity() : null,
|
||||||
Secrets = model.Secrets.GetValueOrDefault()?.ToEntity(),
|
Secrets = model.Secrets.IsSpecified ? model.Secrets.Value.ToEntity() : null,
|
||||||
Timestamps = model.Timestamps.GetValueOrDefault()?.ToEntity()
|
Timestamps = model.Timestamps.IsSpecified ? model.Timestamps.Value.ToEntity() : null
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// Stream Game
|
// Stream Game
|
||||||
@@ -56,11 +56,9 @@
|
|||||||
|
|
||||||
public static GameParty ToEntity(this API.GameParty model)
|
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
|
// Discord will probably send bad data since they don't validate anything
|
||||||
int current = 0, cap = 0;
|
int current = 0, cap = 0;
|
||||||
if (model.Size.Length == 2)
|
if (model.Size?.Length == 2)
|
||||||
{
|
{
|
||||||
current = model.Size[0];
|
current = model.Size[0];
|
||||||
cap = model.Size[1];
|
cap = model.Size[1];
|
||||||
|
|||||||
Reference in New Issue
Block a user