@@ -511,7 +511,12 @@ namespace Discord.WebSocket | |||||
if (model.GuildId.IsSpecified) | if (model.GuildId.IsSpecified) | ||||
{ | { | ||||
var guild = State.GetGuild(model.GuildId.Value); | var guild = State.GetGuild(model.GuildId.Value); | ||||
sticker = guild.AddOrUpdateSticker(model); | |||||
// since the sticker can be from another guild, check if we are in the guild or its in the cache | |||||
if (guild != null) | |||||
sticker = guild.AddOrUpdateSticker(model); | |||||
else | |||||
sticker = SocketSticker.Create(this, model); | |||||
return sticker; | return sticker; | ||||
} | } | ||||
else | else | ||||
@@ -1240,10 +1240,10 @@ namespace Discord.WebSocket | |||||
/// </returns> | /// </returns> | ||||
public async ValueTask<SocketCustomSticker> GetStickerAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null) | public async ValueTask<SocketCustomSticker> GetStickerAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null) | ||||
{ | { | ||||
var sticker = _stickers[id]; | |||||
var sticker = _stickers.FirstOrDefault(x => x.Key == id); | |||||
if (sticker != null) | |||||
return sticker; | |||||
if (sticker.Value != null) | |||||
return sticker.Value; | |||||
if (mode == CacheMode.CacheOnly) | if (mode == CacheMode.CacheOnly) | ||||
return null; | return null; | ||||
@@ -174,17 +174,16 @@ namespace Discord.WebSocket | |||||
SocketSticker sticker = null; | SocketSticker sticker = null; | ||||
if (guild != null) | if (guild != null) | ||||
{ | |||||
sticker = guild.GetSticker(stickerItem.Id); | sticker = guild.GetSticker(stickerItem.Id); | ||||
} | |||||
if(sticker == null) | |||||
{ | |||||
if (sticker == null) | |||||
sticker = Discord.GetSticker(stickerItem.Id); | sticker = Discord.GetSticker(stickerItem.Id); | ||||
} | |||||
// if its still null, create an unknown | // if its still null, create an unknown | ||||
sticker = SocketUnknownSticker.Create(Discord, stickerItem); | |||||
if (sticker == null) | |||||
sticker = SocketUnknownSticker.Create(Discord, stickerItem); | |||||
stickers.Add(sticker); | |||||
} | } | ||||
_stickers = stickers.ToImmutable(); | _stickers = stickers.ToImmutable(); | ||||
@@ -70,7 +70,7 @@ namespace Discord.WebSocket | |||||
internal SocketCustomSticker Clone() => MemberwiseClone() as SocketCustomSticker; | internal SocketCustomSticker Clone() => MemberwiseClone() as SocketCustomSticker; | ||||
private string DebuggerDisplay => $"{Name} in {Guild.Name} ({Id})"; | |||||
private new string DebuggerDisplay => Guild == null ? base.DebuggerDisplay : $"{Name} in {Guild.Name} ({Id})"; | |||||
// ICustomSticker | // ICustomSticker | ||||
ulong? ICustomSticker.AuthorId | ulong? ICustomSticker.AuthorId | ||||
@@ -76,7 +76,7 @@ namespace Discord.WebSocket | |||||
} | } | ||||
} | } | ||||
private string DebuggerDisplay => $"{Name} ({Id})"; | |||||
internal string DebuggerDisplay => $"{Name} ({Id})"; | |||||
/// <inheritdoc/> | /// <inheritdoc/> | ||||
public override bool Equals(object obj) | public override bool Equals(object obj) | ||||