using Discord.WebSocket;
using Newtonsoft.Json.Linq;
using Noikoio.RegexBot.ConfigItem;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Noikoio.RegexBot.Module.EntryAutoRole
{
///
/// Automatically sets a specified role
///
class EntryAutoRole : BotModule
{
private List _roleWaitlist;
private object _roleWaitLock = new object();
// TODO make use of this later if/when some shutdown handler gets added
// (else it continues running in debug after the client has been disposed)
private readonly CancellationTokenSource _workerCancel;
// Config:
// Role: string - Name or ID of the role to apply. Takes EntityName format.
// WaitTime: number - Amount of time in seconds to wait until applying the role to a new user.
public EntryAutoRole(DiscordSocketClient client) : base(client)
{
client.GuildAvailable += Client_GuildAvailable;
client.UserJoined += Client_UserJoined;
client.UserLeft += Client_UserLeft;
_roleWaitlist = new List();
_workerCancel = new CancellationTokenSource();
Task.Factory.StartNew(Worker, _workerCancel.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
}
public override Task