public async Task AnnounceToChannel(string type, string id) { switch (type) { case "event": await EventDiscordHandler.HandleAdded(ContainerCache.GetEventWithId(id)); break; case "linenews": await LineNewsDiscordHandler.HandleAdded(ContainerCache.GetLineNewsWithId(id)); break; case "popupnews": await PopUpNewsDiscordHandler.HandleAdded(ContainerCache.GetPopUpNewsWithId(id)); break; case "present": await PresentDiscordHandler.HandleAdded(ContainerCache.GetPresentWithId(id)); break; default: throw new Exception("Invalid type (must be event, linenews, popupnews, or present)"); } await Context.Channel.SendMessageAsync("**[Admin]** OK, notified"); }
public async Task Execute(string id = null, string languageString = null) { // Get the language Language language = DiscordUtil.GetDefaultLanguage(Context.Guild, languageString); // Check for no ID if (id == null) { await ListCommand.ListContainers(FileType.PopUpNews, language, Context); return; } // Get the PopUpNews with this ID PopUpNews popUpNews = ContainerCache.GetPopUpNewsWithId(id); // Check if this exists if (popUpNews == null) { throw new LocalizedException("popup_news.not_found"); } // Localize the description string localizedDescription = string.Format(Localizer.Localize("popup_news.description", language), popUpNews.ContentText[language], $"https://smash.oatmealdome.me/popup_news/{popUpNews.Id}/{language.GetCode()}/"); // Construct the Embed Embed embed = new EmbedBuilder() .WithTitle(popUpNews.TitleText[language]) .WithDescription(localizedDescription) .AddField(Localizer.Localize("popup_news.start_time", language), Localizer.LocalizeDateTime(popUpNews.StartDateTime, language), true) .AddField(Localizer.Localize("popup_news.end_time", language), Localizer.LocalizeDateTime(popUpNews.EndDateTime, language), true) .WithImageUrl($"https://cdn.oatmealdome.me/smash/popup_news/{popUpNews.Id}/image.jpg") .Build(); await Context.Channel.SendMessageAsync(embed : embed); }