public async Task GetChangelogsAsync(OldGlobal g, int page = 1) { if (!g.Changelogs.Exists()) { await ReplyAsync("There are no changelogs in the storage."); return; } if (g.Changelogs.Count == 0) { await ReplyAsync("There are no changelogs in the storage."); return; } List <Changelog> changelogs = g.Changelogs.OrderByDescending(x => x.Date).ToList(); page = page.InRange(1, changelogs.Count) - 1; EmbedBuilder e = changelogs[page].Generate(); EmbedFooterBuilder f = new EmbedFooterBuilder(); f.WithText(e.Footer.Text + $" | Page {page} of {changelogs.Count}"); e.WithFooter(f); await ReplyAsync(embed : e.Build()); }
public async Task RestoreReportAsync(OrikivoCommandContext ctx, OldGlobal g, string jumpUrl) { string[] ids = jumpUrl.Substring(JUMP_BASE.Length).Split('/'); ulong guildId = ulong.Parse(ids[0]); ulong channelId = ulong.Parse(ids[1]); ulong messageId = ulong.Parse(ids[2]); await RestoreReportAsync(ctx, g, guildId, channelId, messageId); }
public async Task AcceptReportAsync(OrikivoCommandContext ctx, OldGlobal g, ulong id) { if (g.TryGetReport(id, out Report report)) { OldAccount a = ctx.Data.GetOrAddAccount(report.Author.Id); await g.AcceptReport(a, ctx, id); ctx.Data.Update(a); ctx.Data.Update(g); } }
public async Task GetChangelogAsync(OldGlobal g, ulong id) { if (g.TryGetChangelog(id, out Changelog changelog)) { await ReplyAsync(embed : changelog.Generate().Build()); return; } await ReplyAsync("This changelog doesn't exist."); }
public static string TryGetPath<T>(T obj) { string path = TryGetDirectory<T>(); path += obj switch { IStorable storable => $"\\{storable.Id}.{Locator.Output}", OldGlobal _ => $"global.{Locator.Output}", _ => $"{obj}.{Locator.Output}" }; return path; }
public async Task GetReportAsync(OldGlobal g, ulong id) { OldAccount a = Context.Account; if (g.TryGetReport(id, out Report r)) { await ReplyAsync(embed : r.Generate(a).Build()); return; } Embed e = EmbedData.Throw(Context, "Invalid report.", $"R({id}) could not be found in the report collection.", false); await ReplyAsync(embed : e); }
public async Task BuildReportAsync(OldGlobal g, OldAccount a, OriReportPriorityType type, string command, ulong id, string content, string subject = null) { if (g.Reports.Any(x => x.Id == id) || g.AcceptedReports.Any(x => x.Id == id)) { await ReplyAsync("A report of this id already exists."); return; } Report r = new Report(a, type, id, command, content, subject); g.LogReport(r); await(_client.GetChannel(_bugs) as SocketTextChannel).SendMessageAsync(embed: r.Generate(a).Build()); await ReplyAsync($"Your report ({id}) has been built."); }
public async Task AddChangelogAsync(OldGlobal g, string name, string content, UpdateType type, ulong id) { if (g.Changelogs.Any(x => x.Id == id)) { await ReplyAsync("A changelog of this id already exists."); return; } Changelog c = new Changelog(g, name, content, type, id); g.AddChangelog(c); await(_client.GetChannel(_changelogs) as SocketTextChannel).SendMessageAsync(embed: c.Generate().Build()); await ReplyAsync($"Changelog built. You may view it at `changelog {c.Id}`."); }
public async Task RestoreReportAsync(OrikivoCommandContext ctx, OldGlobal g, RestUserMessage msg) { if (msg.Author.Id != _client.CurrentUser.Id) { await ReplyAsync("A report can only be restored from the messages I send."); return; } Report r = new Report(ctx, msg); if (g.Reports.Any(x => x.Id == r.Id) || g.AcceptedReports.Any(x => x.Id == r.Id)) { await ReplyAsync("A report of this id already exists."); return; } g.LogReport(r); await ReplyAsync($"Report {r.Id} has been restored."); }
public async Task GetReportsAsync(OldGlobal g, int page = 1) { EmbedBuilder e = EmbedData.DefaultEmbed; EmbedFooterBuilder f = new EmbedFooterBuilder(); f.WithText($"{EmojiIndex.Report} Reports"); e.WithFooter(f); const int MAX_DESC = 1024; string desc = ""; List <string> list = new List <string>(); List <string> descriptions = new List <string>(); List <Report> reports = g.Reports; List <Report> accepted = g.AcceptedReports; foreach (Report accept in accepted) { list.Add("**+** " + accept.ToString(Context.Account)); } foreach (Report r in reports) { list.Add(r.ToString(Context.Account)); } if (!list.Funct()) { await ReplyAsync(embed : EmbedData.Throw(Context, "Empty collection.", "There are currently no reports.", false)); return; } Embed q = EmbedData.GenerateEmbedList(list, page, e); await ReplyAsync(embed : q); }
public async Task RestoreReportAsync(OrikivoCommandContext ctx, OldGlobal g, ulong guildId, ulong channelId, ulong messageId) { if (!_client.Guilds.Any(x => x.Id == guildId)) { await ctx.Channel.SendMessageAsync("I need to be in the server that this report was sent in."); return; } SocketGuild guild = _client.GetGuild(guildId); if (!guild.TextChannels.Any(x => x.Id == channelId)) { await ctx.Channel.SendMessageAsync("The channel that was specified no longer exists in this server."); return; } SocketTextChannel channel = guild.GetTextChannel(channelId); RestUserMessage message = (channel.GetMessageAsync(messageId).Result as RestUserMessage); await RestoreReportAsync(ctx, g, message); }
public async Task RestoreReportAsync(OrikivoCommandContext ctx, OldGlobal g, ulong id) { RestUserMessage msg = await(_client.GetChannel(_bugs) as SocketTextChannel).GetMessageAsync(id) as RestUserMessage; await RestoreReportAsync(ctx, g, msg); }