Remove a few unnecessary extensions

This commit is contained in:
Ske 2020-05-01 17:38:16 +02:00
parent 48833639e2
commit b927d0c2b7
3 changed files with 3 additions and 32 deletions

View File

@ -61,7 +61,7 @@ namespace PluralKit.Bot
if (target.System != ctx.System.Id) throw Errors.NotOwnMemberError; if (target.System != ctx.System.Id) throw Errors.NotOwnMemberError;
else if (user != null) else if (user != null)
{ {
if (!user.HasAvatar()) throw Errors.UserHasNoAvatar; //TODO: is this necessary? if (user.AvatarHash == null) throw Errors.UserHasNoAvatar;
target.AvatarUrl = user.GetAvatarUrl(ImageFormat.Png, size: 256); target.AvatarUrl = user.GetAvatarUrl(ImageFormat.Png, size: 256);
await _data.SaveMember(target); await _data.SaveMember(target);
@ -131,7 +131,7 @@ namespace PluralKit.Bot
if (user != null) if (user != null)
{ {
if (!user.HasAvatar()) throw Errors.UserHasNoAvatar; if (user.AvatarHash == null) throw Errors.UserHasNoAvatar;
guildData.AvatarUrl = user.GetAvatarUrl(ImageFormat.Png, size: 256); guildData.AvatarUrl = user.GetAvatarUrl(ImageFormat.Png, size: 256);
await _data.SetMemberGuildSettings(target, ctx.Guild.Id, guildData); await _data.SetMemberGuildSettings(target, ctx.Guild.Id, guildData);

View File

@ -144,7 +144,7 @@ namespace PluralKit.Bot
var member = await ctx.MatchUser(); var member = await ctx.MatchUser();
if (member != null) if (member != null)
{ {
if (!member.HasAvatar()) throw Errors.UserHasNoAvatar; if (member.AvatarHash == null) throw Errors.UserHasNoAvatar;
ctx.System.AvatarUrl = member.GetAvatarUrl(ImageFormat.Png, size: 256); ctx.System.AvatarUrl = member.GetAvatarUrl(ImageFormat.Png, size: 256);
await _data.SaveSystem(ctx.System); await _data.SaveSystem(ctx.System);

View File

@ -1,29 +0,0 @@
using DSharpPlus;
using DSharpPlus.Entities;
using System.Net.WebSockets;
namespace PluralKit.Bot
{
static class Extensions
{
//Unfortunately D#+ doesn't expose the connection state of the client, so we have to test for it instead
public static bool IsConnected(this DiscordClient client)
{
try
{
client.GetConnectionsAsync().GetAwaiter().GetResult();
}
catch(WebSocketException)
{
return false;
}
return true;
}
public static bool HasAvatar(this DiscordUser user)
{
return user.AvatarUrl != user.DefaultAvatarUrl;
}
}
}