コード例 #1
0
        public ReactionEvent(BotConfig bc, DiscordSocketClient client, CurrencyService cs, int amount)
        {
            _bc         = bc;
            _log        = LogManager.GetCurrentClassLogger();
            _client     = client;
            _botUser    = client.CurrentUser;
            Source      = new CancellationTokenSource();
            CancelToken = Source.Token;

            var _ = Task.Run(async() =>
            {
                var users = new List <ulong>();
                while (!CancelToken.IsCancellationRequested)
                {
                    await Task.Delay(1000).ConfigureAwait(false);
                    while (_toGiveTo.TryDequeue(out var usrId))
                    {
                        users.Add(usrId);
                    }

                    if (users.Count > 0)
                    {
                        await cs.AddToManyAsync("", amount, users.ToArray()).ConfigureAwait(false);
                    }

                    users.Clear();
                }
            }, CancelToken);
        }