public async Task Execute(string containerType, string specifiedLanguage = null) { // Get the language Language language = DiscordUtil.GetDefaultLanguage(Context.Guild, specifiedLanguage); // Get the FileType FileType fileType; if (containerType == "linenews") { fileType = FileType.LineNews; } if (containerType == "popupnews") { fileType = FileType.PopUpNews; } else if (containerType == "present") { fileType = FileType.Present; } else if (containerType == "event") { fileType = FileType.Event; } else { throw new LocalizedException("list.unknown_file_type"); } // Get the list await ListContainers(fileType, language, Context); }
public SetupFlow(IUser user, IGuild guild, ISocketMessageChannel channel, IEnumerable <Language> validLangs, bool isAdmin) : base(user, channel) { Guild = guild; ValidLanguages = validLangs; DefaultLanguage = DiscordUtil.GetDefaultLanguage(guild, channel); IsAdminMode = isAdmin; }
public async Task Execute(string romTypeStr = null, string languageStr = null) { // Parse the specified RomType RomType romType; if (romTypeStr != null) { // Get the RomType romType = (RomType)EnumUtil.GetEnumValueFromString(typeof(RomType), romTypeStr); } else { // Default to North America romType = RomType.NorthAmerica; } // Get the FestivalSetting for the specified RomType FestivalSetting festivalSetting = FileCache.GetLatestFestivalSettingForRomType(romType); // Get the default language Language language = DiscordUtil.GetDefaultLanguage(Context.Guild, languageStr); // Get the Color for the neutral team System.Drawing.Color drawingColor = festivalSetting.Teams[2].GetColor4fAsColor(); // Localize the RomType string localizedRomType = Localizer.Localize($"romtype.{romType.ToString().ToLower()}", language); // Use the special title if necessary string title; if (festivalSetting.SpecialType != null) { // Localize the special type string localizedSpecialType = Localizer.Localize($"festival.special_type.{festivalSetting.SpecialType.ToLower()}", language); // Localize the title title = string.Format(Localizer.Localize("festival.title_special", language), localizedRomType, localizedSpecialType); } else { // Use the standard title title = string.Format(Localizer.Localize("festival.title", language), localizedRomType); } // Begin building an embed EmbedBuilder embedBuilder = new EmbedBuilder() .WithTitle(title) .AddField(Localizer.Localize("festival.team_alpha", language), $"**{festivalSetting.Teams[0].Name[language]}**", true) .AddField(Localizer.Localize("festival.team_bravo", language), $"**{festivalSetting.Teams[1].Name[language]}**", true) .AddField(Localizer.Localize("festival.rule", language), BlitzLocalizer.LocalizeRule(festivalSetting.VersusRule, language), true) .AddField(Localizer.Localize("festival.special_stage", language), BlitzLocalizer.LocalizeStage(festivalSetting.SpecialStage, language), true) .AddField(Localizer.Localize("festival.announcement_time", language), Localizer.LocalizeDateTime(festivalSetting.Times.Announcement, language)) .AddField(Localizer.Localize("festival.period", language), string.Format(Localizer.Localize("festival.period_format", language), Localizer.LocalizeDateTime(festivalSetting.Times.Start, language), Localizer.LocalizeDateTime(festivalSetting.Times.End, language))) .AddField(Localizer.Localize("festival.results_time", language), Localizer.LocalizeDateTime(festivalSetting.Times.Result, language)) .WithImageUrl($"https://cdn.oatmealdome.me/splatoon/festival/{romType.ToString()}/{festivalSetting.FestivalId}/panel.png") .WithColor(new Color(drawingColor.R, drawingColor.G, drawingColor.B)); await Context.Channel.SendMessageAsync(embed : embedBuilder.Build()); }
public async Task Execute(string languageStr = null) { // Get the language Language language = DiscordUtil.GetDefaultLanguage(Context.Guild, languageStr); // Send the interactive message await DiscordBot.SendInteractiveMessageAsync(Context.Channel, new CoopMessage(Context.User, language)); }
public async Task Support() { // Get the language Language language = DiscordUtil.GetDefaultLanguage(Context.Guild, null); Embed embed = new EmbedBuilder() .WithTitle(Localizer.Localize("support.title", language)) .WithDescription(Localizer.Localize("support.description", language)) .WithColor(Color.Orange) .Build(); await Context.Channel.SendMessageAsync(embed : embed); }
public async Task Execute() { // Get the language Language language = DiscordUtil.GetDefaultLanguage(Context.Guild, null); // Create the Embed Embed embed = new EmbedBuilder() .WithTitle(Localizer.Localize("invite.title", language)) .WithDescription(Localizer.Localize("invite.description", language)) .WithColor(Color.Green) .Build(); await Context.Channel.SendMessageAsync(embed : embed); }
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.LineNews, language, Context); return; } // Get the PopUpNews with this ID LineNews lineNews = ContainerCache.GetLineNewsWithId(id); // Check if this exists if (lineNews == null) { throw new LocalizedException("line_news.not_found"); } // Localize the title string titleKey = "line_news.title"; string localizedTitle = string.Format(Localizer.Localize(titleKey, language), lineNews.Id); // Localize the description string descriptionKey = "line_news.description"; string localizedDescription = string.Format(Localizer.Localize(descriptionKey, language), $"https://smash.oatmealdome.me/line_news/{lineNews.Id}/{language.GetCode()}/"); // Localize the line field name string lineFieldNameKey = "line_news.line_title"; string localizedLineFieldName = Localizer.Localize(lineFieldNameKey, language); // Construct the Embed EmbedBuilder embedBuilder = new EmbedBuilder() .WithTitle(localizedTitle) //.WithDescription(localizedDescription) .AddField(Localizer.Localize("line_news.start_time", language), Localizer.LocalizeDateTime(lineNews.StartDateTime, language), true) .AddField(Localizer.Localize("line_news.end_time", language), Localizer.LocalizeDateTime(lineNews.EndDateTime, language), true); // Add every OneLine foreach (OneLine oneLine in lineNews.OneLines) { embedBuilder.AddField(string.Format(localizedLineFieldName, oneLine.Id), oneLine.Text[language]); } await Context.Channel.SendMessageAsync(embed : embedBuilder.Build()); }
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.Present, language, Context); return; } // Get the Present with this ID Present present = ContainerCache.GetPresentWithId(id); // Check if this exists if (present == null) { throw new LocalizedException("present.not_found"); } // Localize the description string localizedDescription = string.Format(Localizer.Localize("present.description", language), present.ContentText[language], $"https://smash.oatmealdome.me/present/{present.Id}/{language.GetCode()}/"); // Construct the image URL string url = $"https://cdn.oatmealdome.me/smash/present/{present.Id}/image.jpg"; // Construct the Embed Embed embed = new EmbedBuilder() .WithTitle(present.TitleText[language]) .WithDescription(localizedDescription) .AddField(Localizer.Localize("present.start_time", language), Localizer.LocalizeDateTime(present.StartDateTime, language), true) .AddField(Localizer.Localize("present.end_time", language), Localizer.LocalizeDateTime(present.EndDateTime, language), true) .WithImageUrl(url) .Build(); await Context.Channel.SendMessageAsync(embed : embed); }
public override async Task <bool> HandleTextMessage(SocketMessage message) { // Get the guild SocketGuild guild = (message.Channel as SocketGuildChannel).Guild; // Parse the channel ID ulong channelId; try { channelId = MentionUtils.ParseChannel(message.Content); } catch (ArgumentException) { await DiscordUtil.SendErrorMessageByLocalizedDescription(guild, this.Channel, "discord.setup.enter_channel.bad_channel"); return(false); } // Get the channel SocketChannel foundChannel = DiscordBot.GetChannel(channelId); // Check if it exists if (foundChannel == null) { await DiscordUtil.SendErrorMessageByLocalizedDescription(guild, this.Channel, "discord.setup.enter_channel.bad_channel"); return(false); } // Check this channel's guild SocketGuildChannel socketGuildChannel = foundChannel as SocketGuildChannel; // Check that this exists and that it is in the user's guild if (socketGuildChannel == null || socketGuildChannel.Guild.Id != SetupFlow.Guild.Id) { await DiscordUtil.SendErrorMessageByLocalizedDescription(guild, this.Channel, "discord.setup.enter_channel.bad_channel"); return(false); } // Get the text channel SocketTextChannel socketTextChannel = foundChannel as SocketTextChannel; // Check if this is a text channel if (socketTextChannel == null) { await DiscordUtil.SendErrorMessageByLocalizedDescription(guild, this.Channel, "discord.setup.enter_channel.bad_channel"); return(false); } // Check if this already exists as settings if (SetupFlow.GuildSettings.ChannelSettings.Where(p => p.Key == channelId).Count() != 0) { await DiscordUtil.SendErrorMessageByLocalizedDescription(guild, this.Channel, "discord.setup.enter_channel.already_exists"); return(false); } // Get all required permissions List <ChannelPermission> requiredPermissions = new ChannelPermissions(Configuration.LoadedConfiguration.DiscordConfig.Permissions).ToList(); // Get current permissions for this channel ChannelPermissions channelPermissions = guild.CurrentUser.GetPermissions(socketTextChannel); // Get a list of permissions that the bot does not have IEnumerable <ChannelPermission> missingPermissions = requiredPermissions.Where(x => !channelPermissions.Has(x)); // Check if we are missing any if (missingPermissions.Count() > 0) { // Try to get the default language Language language = DiscordUtil.GetDefaultLanguage(guild); // Create the description string for the error message string description = Localizer.Localize("discord.setup.enter_channel.missing_permissions", language) + "\n\n"; // Append the permissions foreach (ChannelPermission permission in missingPermissions) { description += permission.ToString() + "\n"; } // Create an embed await DiscordUtil.SendErrorMessageByDescription(guild, this.Channel, description); return(false); } // Set the new message flag SetupFlow.ShouldSendNewMessage = true; if (SetupFlow.ChannelSettings == null) { // Create a DynamicSettingsData instance SetupFlow.ChannelSettings = new DynamicSettingsData(); // Set the ID SetupFlow.TargetChannelId = channelId; // Proceed to language selection await SetupFlow.SetPage((int)SetupFlowPage.SelectLanguage); } else { // Move the data SetupFlow.GuildSettings.ChannelSettings.TryRemove(SetupFlow.TargetChannelId, out DynamicSettingsData data); SetupFlow.GuildSettings.ChannelSettings.TryAdd(channelId, data); // Set a pre-prompt SetupFlow.ModeSelectPrePromptLocalizable = "discord.setup.mode_select.pre_prompt.edits_saved"; // Change to mode select await SetupFlow.SetPage((int)SetupFlowPage.ModeSelect); } return(false); }