mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-11 16:20:13 +00:00
DRY-ify checking URL length for avatars
This commit is contained in:
parent
7f82a3e63a
commit
05f1ee92ea
4 changed files with 4 additions and 12 deletions
|
|
@ -102,18 +102,11 @@ namespace PluralKit.Bot
|
|||
}
|
||||
|
||||
ctx.CheckSystem().CheckOwnMember(target);
|
||||
await ValidateUrl(avatarArg.Value.Url);
|
||||
await AvatarUtils.VerifyAvatarOrThrow(avatarArg.Value.Url);
|
||||
await UpdateAvatar(location, ctx, target, avatarArg.Value.Url);
|
||||
await PrintResponse(location, ctx, target, avatarArg.Value, guildData);
|
||||
}
|
||||
|
||||
private static Task ValidateUrl(string url)
|
||||
{
|
||||
if (url.Length > Limits.MaxUriLength)
|
||||
throw Errors.InvalidUrl(url);
|
||||
return AvatarUtils.VerifyAvatarOrThrow(url);
|
||||
}
|
||||
|
||||
private Task PrintResponse(AvatarLocation location, Context ctx, PKMember target, ParsedImage avatar,
|
||||
MemberGuildSettings? targetGuildData)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue