DiscordMediaLoader/DML.Client/DMLClient.cs

29 lines
901 B
C#
Raw Normal View History

2017-10-04 15:01:54 +02:00
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
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;
}
}
}