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
|
|
|
|
|
{
|
2020-07-27 11:26:01 +02:00
|
|
|
|
public static DiscordSocketClient Client { get; set; } = new DiscordSocketClient(new DiscordSocketConfig() { DefaultRetryMode = RetryMode.RetryRatelimit | RetryMode.RetryTimeouts });
|
2017-10-04 15:01:54 +02:00
|
|
|
|
|
|
|
|
|
public static async Task<bool> Login(string token)
|
|
|
|
|
{
|
2020-07-27 12:53:05 +02:00
|
|
|
|
await Client.LoginAsync(TokenType.User, token);
|
2017-10-04 15:01:54 +02:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-30 20:35:29 +01:00
|
|
|
|
}
|