Пример #1
0
        public static async Task HandleAdded(LineNews lineNews)
        {
            // Localize the embed title
            Dictionary <Language, string> localizedTitles = Localizer.LocalizeToAllLanguagesWithFormat("line_news.title", Nintendo.SmashUltimate.Bcat.Container.LanguageOrder, lineNews.Id);

            // Localize the embed description
            // Dictionary<Language, string> localizedDescriptions = Localizer.LocalizeToAllLanguages("line_news.more_info", $"https://smash.oatmealdome.me/line_news/{lineNews.Id}/{pair.Key.GetCode()}/");

            // Create localized Embeds
            LocalizedEmbedBuilder localizedEmbedBuilder = new LocalizedEmbedBuilder(Nintendo.SmashUltimate.Bcat.Container.LanguageOrder)
                                                          .WithTitle(localizedTitles)
                                                          //.WithDescription(localizedDescriptions)
                                                          .AddField("line_news.start_time", Localizer.LocalizeDateTimeToAllLanguages(lineNews.StartDateTime))
                                                          .AddField("line_news.end_time", Localizer.LocalizeDateTimeToAllLanguages(lineNews.EndDateTime));

            // Add every OneLine
            foreach (OneLine oneLine in lineNews.OneLines)
            {
                localizedEmbedBuilder.AddField(Localizer.LocalizeToAllLanguagesWithFormat("line_news.line_title", oneLine.Id), oneLine.Text);
            }

            // Create localized Embeds
            Dictionary <Language, Embed> localizedEmbeds = localizedEmbedBuilder.Build();

            // Send the notifications
            await DiscordBot.SendNotificationAsync("**[Line News]**", localizedEmbeds);
        }
Пример #2
0
        public static DiscordEmbed ToDiscordEmbed(this Poll poll, LocalizationService lcs)
        {
            var emb = new LocalizedEmbedBuilder(lcs, poll.Channel.GuildId);

            emb.WithTitle(poll.Question);
            emb.WithLocalizedDescription("str-vote-text");
            emb.WithColor(DiscordColor.Orange);

            for (int i = 0; i < poll.Options.Count; i++)
            {
                if (!string.IsNullOrWhiteSpace(poll.Options[i]))
                {
                    emb.AddField($"{i + 1} : {poll.Options[i]}", $"{poll.Results.Count(kvp => kvp.Value == i)}");
                }
            }

            if (poll.EndTime is { })
Пример #3
0
        public static DiscordEmbed ToEmbed(this ReactionsPoll poll, LocalizationService lcs)
        {
            var emb = new LocalizedEmbedBuilder(lcs, poll.Channel.GuildId);

            emb.WithTitle(poll.Question);
            emb.WithLocalizedDescription("str-vote-react");
            emb.WithColor(DiscordColor.Orange);

            for (int i = 0; i < poll.Options.Count; i++)
            {
                if (!string.IsNullOrWhiteSpace(poll.Options[i]))
                {
                    emb.AddField($"{i + 1}", poll.Options[i], inline: true);
                }
            }

            if (poll.EndTime is { })