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.Event, language, Context); return; } // Get the PopUpNews with this ID Event smashEvent = ContainerCache.GetEventWithId(id); // Check if this exists if (smashEvent == null) { throw new LocalizedException("event.not_found"); } // Localize the description string localizedDescription = string.Format(Localizer.Localize("event.description", language), $"https://smash.oatmealdome.me/event/{smashEvent.Id}/{language.GetCode()}/"); // Construct the Embed Embed embed = new EmbedBuilder() .WithTitle(smashEvent.TitleText[language]) .WithDescription(localizedDescription) .AddField(Localizer.Localize("event.start_time", language), Localizer.LocalizeDateTime(smashEvent.StartDateTime, language), true) .AddField(Localizer.Localize("event.end_time", language), Localizer.LocalizeDateTime(smashEvent.EndDateTime, language), true) .WithImageUrl($"https://cdn.oatmealdome.me/smash/event/{smashEvent.Id}/image.jpg") .Build(); await Context.Channel.SendMessageAsync(embed : embed); }