feat: fetch from REST instead of cache for cross-cluster lookups

This commit is contained in:
spiral
2022-03-09 20:06:53 -05:00
parent d0ad7abb03
commit ae543b9c18
7 changed files with 80 additions and 19 deletions

View File

@@ -49,6 +49,32 @@ public static class DiscordUtils
await rest.CreateReaction(msg.ChannelId, msg.Id, new Emoji { Name = reaction });
}
public static async Task<Guild?> GetGuildOrNull(this DiscordApiClient rest, ulong guildId)
{
try
{
return await rest.GetGuild(guildId);
}
catch (ForbiddenException)
{
// no permission, couldn't fetch, oh well
return null;
}
}
public static async Task<Channel?> GetChannelOrNull(this DiscordApiClient rest, ulong channelId)
{
try
{
return await rest.GetChannel(channelId);
}
catch (ForbiddenException)
{
// no permission, couldn't fetch, oh well
return null;
}
}
public static async Task<Message?> GetMessageOrNull(this DiscordApiClient rest, ulong channelId,
ulong messageId)
{