private static ILocalisable <string> GetString(ILocalisable <EmbedBuilder> embed) { return(new DynamicString(tr => { var localised = embed.Localise(tr); var blocks = new List <string>(); if (localised.Author != null) { blocks.Add($"{localised.Author?.Name}\n{localised.Author?.Url}".Trim()); } if (localised.Title != null) { blocks.Add($"**{localised.Title}**".Trim()); } if (localised.Description != null) { blocks.Add(localised.Description.Trim()); } if (localised.ThumbnailUrl != null) { blocks.Add($"Thumbnail: {localised.ThumbnailUrl}".Trim()); } foreach (var field in localised.Fields) { blocks.Add($"**{field.Name.Trim()}**\n{field.Value.ToString().Trim()}"); } if (localised.ImageUrl != null) { blocks.Add(localised.ImageUrl.Trim()); } blocks.Add(string.Join(" | ", new object[] { localised.Footer?.Text, localised.Timestamp }.Where(v => !string.IsNullOrWhiteSpace(v?.ToString()))).Trim()); return string.Join("\n---------\n", blocks.Where(b => !string.IsNullOrWhiteSpace(b)).ToArray()); })); }
/// <summary> /// Localise the control /// </summary> public void Localise() { ILocalisable localisable = _visualisation as ILocalisable; if (localisable != null) { localisable.Localise(); } }
private ILocalisable <string> ValueViewer(ILocalisable <string> baseValue) => new DynamicString(tr => { var x = baseValue?.Localise(tr); if (string.IsNullOrWhiteSpace(x)) { return(((LocalisedString)SettingText.NOTSET).Localise(tr)); } return(x); });
public LocalisedAuthorBuilder WithUrl(ILocalisable <string> url) { Url = url; return(this); }
protected ValueTask <IUserMessage> ReplyAsync(string key, ReplyType replyType, ILocalisable <EmbedBuilder> embedable, params object[] values) => ReplyAsync(key, replyType, Embedable.FromEmbed(embedable), values);
private bool TrySet(ICommandContext context, IEntity <ulong> entity, TAccept value, out ILocalisable <string> error) { error = Validator(context, value); if (error != null) { return(false); } Editor(entity, s => Setter(s, Converter(context, value))); return(true); }
ISettingEditorCollection ISettingEditorCollection.WithDescription(ILocalisable <string> description) => WithDescription(description);
public ISettingEditorCollection <TSetting> WithDescription(ILocalisable <string> description) { Description = description; return(this); }
public LocalisedFieldBuilder WithName(ILocalisable <string> name) { Name = name; return(this); }
public static Embedable FromEmbed(ILocalisable <EmbedBuilder> embed, Func <ILocalisable <EmbedBuilder>, ILocalisable <string> > stringFormat) => embed == null ? null : new Embedable(embed, stringFormat);
public static Embedable FromEmbed(ILocalisable <EmbedBuilder> embed) => FromEmbed(embed, GetString);
private Embedable(ILocalisable <EmbedBuilder> value, Func <ILocalisable <EmbedBuilder>, ILocalisable <string> > stringFormat) { Builder = value; StringFormatter = stringFormat; }
private async void ReplyAsync(ICommandContext context, ILocalisable <string> message) => await context.Replier.Reply(context.Channel, context.Author).WithMessage(message).SendAsync();
public IReplyContext WithMessage(ILocalisable <string> message) { Message = message; return(this); }
public LocalisedFooterBuilder WithText(ILocalisable <string> text) { Text = text; return(this); }
public IModifyContext ChangeEmbedable(ILocalisable <EmbedBuilder> embedable) => ChangeEmbedable(Commands.Embedable.FromEmbed(embedable));
public LocalisedFooterBuilder WithIconUrl(ILocalisable <string> iconUrl) { IconUrl = iconUrl; return(this); }
public IModifyContext ChangeMessage(ILocalisable <string> message) { Text = message; return(this); }
public LocalisedFieldBuilder WithValue(ILocalisable <string> value) { Value = value; return(this); }
protected ValueTask <IUserMessage> ReplyAsync(ILocalisable <string> message, IEmbedable embedable) => Reply().WithMessage(message).WithEmbedable(embedable).SendAsync();
public ISettingEditorCollection <TSetting> WithNotes(ILocalisable <string> notes) { Notes = notes; return(this); }
protected ValueTask <IUserMessage> ReplyAsync(string key, ILocalisable <EmbedBuilder> embedable) => ReplyAsync(key, Embedable.FromEmbed(embedable));
ISettingEditorCollection ISettingEditorCollection.WithNotes(ILocalisable <string> notes) => WithNotes(notes);
public bool TrySet(ICommandContext context, IEntity <ulong> entity, object value, out ILocalisable <string> error) => TrySet(context, entity, (TAccept)value, out error);