public ILocalisable <EmbedBuilder> GetEmbed() { var builder = new LocalisedEmbedBuilder { Color = new Color(135, 206, 250), //System.Drawing.Color.LightSkyBlue.ToDiscord(), Title = new LocalisedString(SINGLE_TITLE, ReplyType.Info, Command.Name), Timestamp = DateTime.Now, Footer = new LocalisedFooterBuilder().WithRawIconUrl(BotUser.GetAvatarUrl()).WithText(SINGLE_FOOTER, BotUser.Username), }.WithDescription(Command.Description ?? SINGLE_NODESCRIPTION); builder.AddInlineField(f => f.WithName(TBLocalisation.GROUP).WithValue(Group)); if (!string.IsNullOrWhiteSpace(Aliases)) { builder.AddInlineField(f => f.WithName(TBLocalisation.ALIASES).WithRawValue(Format.Sanitize(Aliases))); } builder.AddField(f => f.WithName(TBLocalisation.USAGE).WithValue(Usage)); if (Flags.Count != 0) { builder.AddField(f => f.WithName(TBLocalisation.FLAGS).WithValue(Flag)); } if (Notes != null && !string.IsNullOrWhiteSpace(Notes.Key)) { builder.AddField(f => f.WithName(TBLocalisation.NOTES).WithValue(tr => Notes.Localise(tr) + (Usages.Count > 0 ? NotesFooter.Localise(tr) : ""))); } else if (Usages.Count > 0) { builder.AddField(f => f.WithName(TBLocalisation.NOTES).WithValue(NotesFooter)); } return(builder); }
protected virtual LocalisedEmbedBuilder GetBaseEmbed() => new LocalisedEmbedBuilder { Footer = new LocalisedFooterBuilder().WithRawIconUrl(BotUser.GetAvatarUrl()) .WithText(Footer), Author = new LocalisedAuthorBuilder().WithName(Title), Timestamp = DateTime.Now };
protected override LocalisedEmbedBuilder GetBaseEmbed() => new LocalisedEmbedBuilder { Color = System.Drawing.Color.LightBlue.ToDiscord(), Footer = new LocalisedFooterBuilder().WithRawIconUrl(BotUser.GetAvatarUrl()) .WithText(Footer), Timestamp = DateTime.Now } .WithTitle(Title) .WithDescription(Description);
public async Task <BanAppeal> CreateAppeal(IGuild guild, BotUser user) { var existing = GetAppeal(guild, user.Id); if (existing != null) { return(existing); } var appeals = GetAllAppeals(guild); if (appeals.AppealCategory == null) { appeals.AppealCategory = await guild.CreateCategoryAsync("Ban Appeals", x => { x.PermissionOverwrites = new List <Overwrite>() { new Overwrite(guild.EveryoneRole.Id, PermissionTarget.Role, Program.NoPerms) }; }); } var txt = await guild.CreateTextChannelAsync($"appeal-{user.Name}", x => { x.Topic = user.Id.ToString(); x.CategoryId = appeals.AppealCategory.Id; x.Position = 0; }); var appeal = new BanAppeal(); appeal.Appellant = user; appeal.Guild = guild; appeal.AppealChannel = txt; appeals.Appeals[user.Id] = appeal; OnSave(); await txt.SendMessageAsync(embed : new EmbedBuilder() .WithAuthor(user.Name, user.GetAvatarUrl()) .WithTitle($"Ban Appeal") .WithDescription($"Original Ban Reason:\r\n> {(appeal.Ban.Reason ?? "No reason provided")}") .WithFooter($"{Program.Prefix}appeal mute | {Program.Prefix}appeal approve | {Program.Prefix}appeal reject") .WithColor(Color.Red) .Build()); return(appeal); }
protected async Task SetSettingAsync(string key, string value = null) { var setting = Find(key); if (setting == null) { await ReplyAsync(SettingText.KEY_NOTFOUND, ReplyType.Error, key); } else { var readerResult = await Readers.Read(setting.Type, Context, value); if (!readerResult.IsSuccess) { await ReplyAsync(SettingText.VALUE_INVALID, ReplyType.Error, setting.Name, value); return; } var oldValue = setting.Display(Context, SettingContext); if (!setting.TrySet(Context, SettingContext, readerResult.Best, out var errors)) { await ReplyAsync(errors); } else { var newValue = setting.Display(Context, SettingContext); var builder = new LocalisedEmbedBuilder { Footer = new LocalisedFooterBuilder().WithIconUrl(BotUser.GetAvatarUrl()) .WithText(BotUser.Username), Timestamp = DateTime.Now, Color = new Color(135, 206, 235), //System.Drawing.Color.SkyBlue.ToDiscord(), }.WithTitle(SettingText.VALUE_CHANGED_TITLE, setting.Name) .AddField(f => f.WithName(SettingText.VALUE_OLD) .WithValue(ValueViewer(oldValue))) .AddField(f => f.WithName(SettingText.VALUE_NEW) .WithValue(ValueViewer(newValue))); await ReplyAsync(builder); } } }
protected async Task ToggleSettingAsync(string key) { var setting = Find(key); if (setting == null) { await ReplyAsync(SettingText.KEY_NOTFOUND, ReplyType.Error, key); } else if (setting.Type != typeof(bool)) { await ReplyAsync(SettingText.UNABLE_TOGGLE, ReplyType.Error, key); } else { var oldValue = (bool)setting.Get(SettingContext); var oldDisplay = setting.Display(Context, SettingContext); if (!setting.TrySet(Context, SettingContext, !oldValue, out var errors)) { await ReplyAsync(errors); } else { var newDisplay = setting.Display(Context, SettingContext); var builder = new LocalisedEmbedBuilder { Footer = new LocalisedFooterBuilder().WithIconUrl(BotUser.GetAvatarUrl()) .WithText(BotUser.Username), Timestamp = DateTime.Now, Color = new Color(135, 206, 235), //System.Drawing.Color.SkyBlue.ToDiscord(), }.WithTitle(SettingText.VALUE_CHANGED_TITLE, setting.Name) .AddField(f => f.WithName(SettingText.VALUE_OLD) .WithValue(ValueViewer(oldDisplay))) .AddField(f => f.WithName(SettingText.VALUE_NEW) .WithValue(ValueViewer(newDisplay))); await ReplyAsync(builder); } } }
async Task PrestigeStatsAsync(int stage, [CallFlag('b', "bos", Flag.PRESTIGE_B)] int bosLevel = -1, [CallFlag('c', "clan", Flag.PRESTIGE_C)] int clanLevel = -1, [CallFlag('i', "ip", Flag.PRESTIGE_I)] int ipLevel = -1) { ipLevel = Math.Min(62, ipLevel); var startingStage = Math.Max(1, stage * Calculator.AdvanceStart(clanLevel.Clamp(0, int.MaxValue)) - 1); var totalRelics = Calculator.RelicsEarned(stage, bosLevel.Clamp(0, int.MaxValue)); var baseRelics = Calculator.RelicsEarned(stage, 0); var enemiesToKill = Enumerable.Range(startingStage, stage - startingStage).Sum(s => Calculator.TitansOnStage(s, ipLevel.Clamp(0, int.MaxValue))); var timeTaken = Calculator.RunTime(startingStage, stage, ipLevel.Clamp(0, int.MaxValue), 1); var timeTakenSplash = Calculator.RunTime(startingStage, stage, ipLevel.Clamp(0, int.MaxValue), 4); List <LocalisedString> description = new List <LocalisedString>(); if (bosLevel > 0) { description.Add(new LocalisedString(PrestigeText.DESCRIPTION_BOS, bosLevel)); } if (clanLevel > 0) { description.Add(new LocalisedString(PrestigeText.DESCRIPTION_CLAN, clanLevel)); } if (ipLevel > 0) { description.Add(new LocalisedString(PrestigeText.DESCRIPTION_IP, ipLevel)); } var builder = new LocalisedEmbedBuilder { Description = LocalisedString.Join("\n", description.ToArray()), Color = System.Drawing.Color.Gold.ToDiscord(), Footer = new LocalisedFooterBuilder().WithText(PrestigeText.FOOTER).WithRawIconUrl(BotUser.GetAvatarUrl()) } .WithTitle(PrestigeText.TITLE, stage) .AddInlineField(f => f.WithName(PrestigeText.FIELD_STARTINGSTAGE).WithValue(startingStage)) .AddInlineField(f => f.WithName(PrestigeText.FIELD_RELICS).WithValue(PrestigeText.FIELD_RELICS_VALUE, baseRelics, totalRelics - baseRelics, totalRelics)) .AddInlineField(f => f.WithName(PrestigeText.FIELD_ENEMIES).WithValue(PrestigeText.FIELD_ENEMIES_VALUE, enemiesToKill, stage - startingStage)) .AddInlineField(f => f.WithName(PrestigeText.FIELD_TIME).WithValue(PrestigeText.FIELD_TIME_VALUE, timeTaken, timeTakenSplash)); await ReplyAsync(builder); }
protected async Task ListSettingsAsync(string settingGroup = null) { var builder = new LocalisedEmbedBuilder { Color = new Color(135, 206, 235), //System.Drawing.Color.SkyBlue.ToDiscord(), Timestamp = DateTime.Now, Footer = new LocalisedFooterBuilder().WithRawIconUrl(BotUser.GetAvatarUrl()) .WithText(SettingText.FOOTERTEXT, BotUser.Username) }; if (Settings.Count == 1) { settingGroup = Settings.First().Name; } if (settingGroup == null) { builder.WithTitle(SettingText.TITLE_NOGROUP); var desc = string.Join("\n", Settings.Select(g => g.Name)); if (string.IsNullOrWhiteSpace(desc)) { builder.WithDescription(SettingText.DESCRIPTION_NOSETTINGS); } else { builder.WithRawDescription(desc); } await ReplyAsync(builder); return; } var groups = Settings.Where(g => g.Name.ToLower() == settingGroup.ToLower()).ToList(); if (groups.Count() == 0) { await ReplyAsync(SettingText.INVALIDGROUP, ReplyType.Error, settingGroup); return; } builder.WithTitle(SettingText.TITLE_GROUP, groups.First().Name); foreach (var setting in groups.SelectMany(s => s)) { var value = setting.Display(Context, SettingContext); if (value == null) { builder.AddInlineField(f => f.WithRawName(setting.Name).WithValue(SettingText.NOTSET)); } else { builder.AddInlineField(f => f.WithRawName(setting.Name).WithValue(value)); } } var descriptions = LocalisedString.JoinEnumerable("\n", groups.Where(g => g.Description != null).Select(g => g.Description)); var notes = LocalisedString.JoinEnumerable("\n", groups.Where(g => g.Notes != null).Select(g => g.Notes)); if (groups.Exists(g => g.Description != null)) { builder.WithDescription(descriptions); } if (groups.Exists(g => g.Notes != null)) { builder.AddField(f => f.WithName(TBLocalisation.NOTES).WithValue(notes)); } await ReplyAsync(builder); }