Remove a few unnecessary extensions
This commit is contained in:
parent
48833639e2
commit
b927d0c2b7
@ -61,7 +61,7 @@ namespace PluralKit.Bot
|
||||
if (target.System != ctx.System.Id) throw Errors.NotOwnMemberError;
|
||||
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);
|
||||
|
||||
await _data.SaveMember(target);
|
||||
@ -131,7 +131,7 @@ namespace PluralKit.Bot
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
if (!user.HasAvatar()) throw Errors.UserHasNoAvatar;
|
||||
if (user.AvatarHash == null) throw Errors.UserHasNoAvatar;
|
||||
guildData.AvatarUrl = user.GetAvatarUrl(ImageFormat.Png, size: 256);
|
||||
await _data.SetMemberGuildSettings(target, ctx.Guild.Id, guildData);
|
||||
|
||||
|
@ -144,7 +144,7 @@ namespace PluralKit.Bot
|
||||
var member = await ctx.MatchUser();
|
||||
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);
|
||||
await _data.SaveSystem(ctx.System);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user