Beispiel #1
0
        public static async ValueTask <Channel?> GetOrFetchChannel(this IDiscordCache cache, DiscordApiClient rest, ulong channelId)
        {
            if (cache.TryGetChannel(channelId, out var cacheChannel))
            {
                return(cacheChannel);
            }

            var restChannel = await rest.GetChannel(channelId);

            if (restChannel != null)
            {
                await cache.SaveChannel(restChannel);
            }
            return(restChannel);
        }