public static async Task SelectiveUpdate(Clan clan) { Log.Information("Scanning for changes for " + clan.details.Name); var changed = await SpreadsheetTools.CheckForChangesAsync(clan); if (changed.TotalChanges > 0) { await SpreadsheetTools.SelectiveUpdate(clan, changed, null, null); DiscordEmbed discordEmbed; if (changed.TotalChanges == 1) { discordEmbed = Core.Discord.CreateFancyMessage(DiscordColor.SpringGreen, "Processed changes for " + clan.details.Name, "Automatically processed 1 entry."); } else { discordEmbed = Core.Discord.CreateFancyMessage(DiscordColor.SpringGreen, "Processed changes for " + clan.details.Name, string.Format("Automatically processed {0} entries", changed.TotalChanges)); } List <DiscordMessage> messages = new List <DiscordMessage>(); foreach (var channel in Core.Discord.updatesChannels) { messages.Add(await Core.Discord.SendFancyMessage(channel, discordEmbed)); } } }
public async Task UpdateSpreadSheet(CommandContext ctx, string clanTag) { var roles = ctx.Member.Roles.ToList(); var verification = await IsVerifiedAsync(ctx, true); var clan = await GetClanFromTagOrNameAsync(ctx, clanTag); clanTag = clanTag.ToLower(); if (clan != null && verification == ErrorCode.Qualify && !string.IsNullOrEmpty(clan.details.Tag)) { var discordEmbed = Core.Discord.CreateFancyMessage(DiscordColor.Orange, "Scanning for Changes..."); DiscordMessage msg = await ctx.RespondAsync(discordEmbed); await SpreadsheetTools.Read(clan); var _ = await SpreadsheetTools.CheckForChangesAsync(clan); if (_.TotalChanges > 0) { TimeSpan t = TimeSpan.FromSeconds((_.addedUsers.Count * 5) + (_.updatedUsers.Count * 0.1) + (_.removedUsers.Count * 0.1)); discordEmbed = Core.Discord.CreateFancyMessage(DiscordColor.Yellow, "Found changes", string.Format("{0} change(s) found...", _.TotalChanges), new List <Field>() { new Field("Time Left", t.ToString(@"mm\:ss")) }); await msg.ModifyAsync(discordEmbed); await SpreadsheetTools.SelectiveUpdate(clan, _, new() { msg }, UpdateSpreadsheetProgress); discordEmbed = Core.Discord.CreateFancyMessage(clan.details.DiscordColour, "Done", string.Format("Successfully processed {0} changes.", _.TotalChanges)); await msg.ModifyAsync(discordEmbed); } else { await SpreadsheetTools.SelectiveUpdate(clan); discordEmbed = Core.Discord.CreateFancyMessage(DiscordColor.SpringGreen, "No changes found", "To update steam names, please run a bulk update."); await msg.ModifyAsync(discordEmbed); } await ThankUsage(ctx, clan, 100); } }