public async Task SendLootboxes() { var voters = (await WebUtil.GetVotersAsync()).Select(x => x.Id).Distinct(); int sent = await Timers.SendRewards(voters); Context.Channel.SendMessageAsync($"Broadcasted to {sent}/{voters.Count()} users."); }
public static async void Timer_Voters2(object sender, ElapsedEventArgs e) { if (Interlocked.Exchange(ref VoteLock, 1) == 0) { try { var voters = await WebUtil.GetVotersAsync(); var old = await VoteDb.GetVoters(500); var votersParsed = voters.Select(x => x.Id).ToList(); votersParsed.Reverse(); List <ulong> add = NewEntries(old, votersParsed); if (add.Count > 500) { var ch = await Program.GetClient().GetUser(AppSettings.OwnerId).CreateDMChannelAsync(); string er = "```\n"; foreach (var id in voters.Take(10)) { er += $"{id.Id}\n"; } er += "...\n"; foreach (var id in voters.Skip(add.Count - 10)) { er += $"{id.Id}\n"; } er += "```"; await ch.SendMessageAsync($"Found {add.Count} new voters.\n {er}"); return; } await VoteDb.AddVoters(add); await SendRewards(add); if (add.Count > 0) { Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")} Shipped {add.Count} lootboxes."); } } catch (Exception ex) { SentrySdk.CaptureException(ex); } finally { VoteLock = 0; } } }
public async Task GetVoters(ulong botId = 0) { string er = "```\n"; WebUtil.SetUpDbl(botId == 0 ? Context.Client.CurrentUser.Id : botId); var voters = await WebUtil.GetVotersAsync(); foreach (var id in voters.Take(10)) { er += $"{id.Id}\n"; } er += "...\n"; foreach (var id in voters.Skip(voters.Count - 10)) { er += $"{id.Id}\n"; } er += "```"; await ReplyAsync($"Found {voters.Count} new voters.\n {er}"); }
public async Task MessageVoters([Remainder] string msg = "") { var voters = (await WebUtil.GetVotersAsync()).Select(x => x.Id).Distinct(); int sent = 0; foreach (var x in voters) { try { var ch = await Program.GetClient().GetUser(x).CreateDMChannelAsync(); await ch.SendMessageAsync(msg); sent++; } catch { } } Context.Channel.SendMessageAsync($"Broadcasted to {sent}/{voters.Count()} users."); }