2020-04-24 19:50:28 +00:00
|
|
|
using DSharpPlus;
|
2020-04-24 21:20:34 +00:00
|
|
|
using DSharpPlus.Entities;
|
2020-04-24 19:50:28 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2020-04-24 21:20:34 +00:00
|
|
|
|
|
|
|
public static bool HasAvatar(this DiscordUser user)
|
|
|
|
{
|
|
|
|
return user.AvatarUrl != user.DefaultAvatarUrl;
|
|
|
|
}
|
2020-04-24 19:50:28 +00:00
|
|
|
}
|
|
|
|
}
|