コード例 #1
0
            static void TranslationsSection(EmbedBuilder embed,
                                            LocalizationAccess l)
            {
                l = l["translations"];

                embed.AddField(
                    l["title"],
                    l["text", new { translators = l.Localization["meta"]["translators"] }]);
            }
コード例 #2
0
            static void OpenSourceSection(EmbedBuilder embed,
                                          LocalizationAccess l)
            {
                l = l["openSource"];

                embed.AddField(l["title"],
                               $@"
{l["license"]}
[GitHub](https://github.com/chiyadev/nhitomi)
".Trim());
            }
コード例 #3
0
            static void SourcesSection(EmbedBuilder embed,
                                       LocalizationAccess l)
            {
                l = l["doujins"]["sources"];

                embed.AddField(l["title"],
                               @"
- nhentai — `https://nhentai.net/`
- Hitomi — `https://hitomi.la/`
".Trim());
            }
コード例 #4
0
            void OptionsSection(EmbedBuilder embed,
                                LocalizationAccess l)
            {
                l = l["options"];

                var prefix = _settings.Discord.Prefix;

                embed.AddField(l["title"],
                               $@"
- `{prefix}option language` — {l["language"]}
- `{prefix}option feed add` — {l["feed.add"]}
- `{prefix}option feed remove` — {l["feed.remove"]}
- `{prefix}option feed mode` — {l["feed.mode"]}
".Trim());
            }
コード例 #5
0
            void DoujinsSection(EmbedBuilder embed,
                                LocalizationAccess l)
            {
                l = l["doujins"];

                var prefix = _settings.Discord.Prefix;

                embed.AddField(l["title"],
                               $@"
- `{prefix}get` — {l["get"]}
- `{prefix}from` — {l["from"]}
- `{prefix}read` — {l["read"]}
- `{prefix}download` — {l["download"]}
- `{prefix}search` — {l["search"]}
".Trim());
            }
コード例 #6
0
            static void LanguagesSection(EmbedBuilder embed,
                                         LocalizationAccess l)
            {
                l = l["options"]["languages"];

                var content = new StringBuilder();

                foreach (var localization in Localization.GetAllLocalizations())
                {
                    var culture = localization.Culture;

                    content.AppendLine($"- `{culture.Name}` — {culture.EnglishName} | {culture.NativeName}");
                }

                embed.AddField(l["title"], content.ToString());
            }
コード例 #7
0
            public static Embed CreateEmbed(Doujin doujin,
                                            LocalizationAccess l,
                                            bool isFeed = false)
            {
                return(new EmbedBuilder
                {
                    Title = doujin.OriginalName,
                    Description = doujin.OriginalName == doujin.PrettyName ? null : doujin.PrettyName,
                    Url = GetGalleryUrl(doujin),
                    ImageUrl = $"https://nhitomi.chiya.dev/api/v1/images/{doujin.AccessId}/-1",
                    Color = Color.Green,

                    Author = new EmbedAuthorBuilder
                    {
                        Name = doujin.GetTag(TagType.Artist)?.Value ?? doujin.Source,
                        IconUrl = GetSourceIconUrl(doujin)
                    },

                    Footer = new EmbedFooterBuilder
                    {
                        Text = $"{doujin.Source}/{doujin.SourceId} {(isFeed ? " | feed" : null)}"
                    },

                    Fields = getFields()
                             .Where(x => !string.IsNullOrWhiteSpace(x.value))
                             .Select(x => new EmbedFieldBuilder
                    {
                        Name = x.name,
                        Value = x.value,
                        IsInline = true
                    })
                             .ToList()
                }.Build());

                IEnumerable <(string name, string value)> getFields() => new[]
                {
                    TagType.Language,
                    TagType.Group,
                    TagType.Parody,
                    TagType.Category,
                    TagType.Character,
                    TagType.Tag
                }.Select(type => (l[type.ToString()].ToString(),
                                  string.Join(", ", doujin.GetTags(type).Select(t => t.Value))))
                .Append((l["content"], l["contentValue", new { doujin }]));
            }
コード例 #8
0
            void CollectionsSection(EmbedBuilder embed,
                                    LocalizationAccess l)
            {
                l = l["collections"];

                var prefix = _settings.Discord.Prefix;

                embed.AddField(l["title"],
                               $@"
- `{prefix}collections` — {l["list"]}
- `{prefix}collection {{name}}` — {l["view"]}
- `{prefix}collection {{name}} add` — {l["add"]}
- `{prefix}collection {{name}} remove` — {l["remove"]}
- `{prefix}collection {{name}} sort` — {l["sort"]}
- `{prefix}collection {{name}} delete` — {l["delete"]}
".Trim());
            }