2017-12-16 16:05:09 +01:00
|
|
|
|
using System.Threading.Tasks;
|
2017-10-04 15:01:54 +02:00
|
|
|
|
using Discord;
|
|
|
|
|
using Discord.WebSocket;
|
|
|
|
|
|
|
|
|
|
namespace DML.Client
|
|
|
|
|
{
|
|
|
|
|
public static class DMLClient
|
|
|
|
|
{
|
|
|
|
|
public static DiscordSocketClient Client { get; set; } = new DiscordSocketClient(new DiscordSocketConfig(){DefaultRetryMode = RetryMode.RetryRatelimit|RetryMode.RetryTimeouts});
|
|
|
|
|
|
|
|
|
|
public static async Task<bool> Login(string token)
|
|
|
|
|
{
|
|
|
|
|
await Client.LoginAsync(TokenType.User, token);
|
|
|
|
|
await Client.StartAsync();
|
|
|
|
|
await Task.Delay(1000);
|
|
|
|
|
|
|
|
|
|
while (Client.LoginState == LoginState.LoggingIn || Client.ConnectionState == ConnectionState.Connecting)
|
|
|
|
|
{
|
|
|
|
|
// wait
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Client.LoginState == LoginState.LoggedIn && Client.ConnectionState == ConnectionState.Connected;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|