mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-04-20 00:43:36 +03:00
Remove redundant getters from Extensions
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
9dec46fb9c
commit
0bee68af8a
1 changed files with 0 additions and 14 deletions
|
@ -2,28 +2,14 @@ using System.Text;
|
|||
using DiffPlex.DiffBuilder.Model;
|
||||
using Remora.Discord.API;
|
||||
using Remora.Discord.API.Abstractions.Objects;
|
||||
using Remora.Discord.API.Abstractions.Rest;
|
||||
using Remora.Discord.API.Objects;
|
||||
using Remora.Discord.Caching;
|
||||
using Remora.Discord.Caching.Services;
|
||||
using Remora.Discord.Extensions.Embeds;
|
||||
using Remora.Discord.Extensions.Formatting;
|
||||
using Remora.Rest.Core;
|
||||
using Remora.Results;
|
||||
|
||||
namespace Boyfriend;
|
||||
|
||||
public static class Extensions {
|
||||
public static async Task<Result<IUser>> TryGetUserAsync(
|
||||
this Snowflake userId, CacheService cacheService, IDiscordRestUserAPI userApi, CancellationToken ct) {
|
||||
var cachedUserResult = await cacheService.TryGetValueAsync<IUser>(
|
||||
new KeyHelpers.UserCacheKey(userId), ct);
|
||||
|
||||
if (cachedUserResult.IsDefined(out var cachedUser)) return Result<IUser>.FromSuccess(cachedUser);
|
||||
|
||||
return await userApi.GetUserAsync(userId, ct);
|
||||
}
|
||||
|
||||
public static EmbedBuilder WithUserFooter(this EmbedBuilder builder, IUser user) {
|
||||
var avatarUrlResult = CDN.GetUserAvatarUrl(user, imageSize: 256);
|
||||
var avatarUrl = avatarUrlResult.IsSuccess
|
||||
|
|
Loading…
Add table
Reference in a new issue