//private static Task<RestUserMessage> TEMPLATEFUNCTION(RavenGuild guild, ulong userId, ISocketMessageChannel channel, string[] args) {} private static Task <RestUserMessage> LsSetLevelState(RavenGuild guild, ulong userId, SocketTextChannel channel, LevelSettings option) { guild.GuildSettings.LevelConfig.LevelSettings = option; guild.UserConfiguration[userId] = MessageBox.LsSettingSubmenu; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.LsSettingSubmenu)); }
private static Task <RestUserMessage> LsSetMinXpTime(RavenGuild guild, ulong userId, SocketTextChannel channel, string[] args) { if (args.ElementAtOrDefault(1) is null) { return(channel.SendMessageAsync(GetMissingParam("MinXpTime", typeof(int)))); } if (!int.TryParse(args.ElementAt(1), out int val)) { return(channel.SendMessageAsync(ParamWrongFormat("MinXpTime", typeof(int)))); } // TODO: Unhardcode clamped global xp values if (val < 30) { return(channel.SendMessageAsync("MinXpTime must be greater than or equal to 30.")); } if (val > 180) { return(channel.SendMessageAsync("MinXpTime must not be greater than 180.")); } guild.GuildSettings.LevelConfig.SecondsBetweenXpGiven = (uint)val; guild.UserConfiguration[userId] = MessageBox.LevelSettings; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.LevelSettings)); }
private static Task <RestUserMessage> LsSetMaxXp(RavenGuild guild, ulong userId, SocketTextChannel channel, string[] args) { if (args.ElementAtOrDefault(1) is null) { return(channel.SendMessageAsync(GetMissingParam("MaximumXp", typeof(int)))); } if (!int.TryParse(args.ElementAt(1), out int val)) { return(channel.SendMessageAsync(ParamWrongFormat("MaximumXp", typeof(int)))); } // TODO: Unhardcode clamped global xp values if (val <= 1) { return(channel.SendMessageAsync("MaximumXp must be greater than 1.")); } if (val > 1000) { return(channel.SendMessageAsync("MaximumXp must not be greater than 1000.")); } if (val < guild.GuildSettings.LevelConfig.MinXpGenerated) { return(channel.SendMessageAsync("MaximumXp must not be less than the MinimumXp. They can be equal to remove RNG.")); } guild.GuildSettings.LevelConfig.MaxXpGenerated = val; guild.UserConfiguration[userId] = MessageBox.LevelSettings; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.LevelSettings)); }
private static Task <RestUserMessage> LoggingSetChannel(RavenGuild guild, ulong userId, SocketTextChannel channel, string[] args) { if (args.ElementAtOrDefault(1) is null) // If they didn't provide a channel name { return(channel.SendMessageAsync(GetMissingParam("ChannelName", typeof(string)))); } Console.WriteLine(string.Join('-', args, 1)); var tempChannel = channel.Guild.Channels.FirstOrDefault(x => x.Name == string.Join('-', args.Skip(1)).ToLower()); tempChannel = tempChannel ?? channel.Guild.Channels.FirstOrDefault(x => x.Name.Contains(string.Join('-', args.Skip(1)).ToLower())); if (tempChannel is null) // If we found no matching channels { return(channel.SendMessageAsync("The specified channel could not be found. Please try again.")); } if (!(tempChannel is SocketTextChannel)) // If the channel found was not a valid text channel { return(channel.SendMessageAsync("The specified channel was not a text channel")); } guild.LoggingSettings.ChannelId = tempChannel.Id; guild.UserConfiguration[userId] = MessageBox.LoggingSettings; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.LoggingSettings)); }
private static Task <RestUserMessage> LsRemoveLevelBinding(RavenGuild guild, ulong userId, SocketTextChannel channel, string[] args) { if (args.ElementAtOrDefault(1) is null) { return(channel.SendMessageAsync(GetMissingParam("Level", typeof(byte)))); } if (!byte.TryParse(args.ElementAt(1), out byte val)) { return(channel.SendMessageAsync(ParamWrongFormat("Level", typeof(byte)))); } if (val <= 1) { return(channel.SendMessageAsync("There are no bindings for level 1 or below.")); } if (!guild.GuildSettings.LevelConfig.RankBindings.ContainsKey(val)) { return(channel.SendMessageAsync("There is no rank bound to the specified level.")); } guild.GuildSettings.LevelConfig.RankBindings.Remove(val); guild.UserConfiguration[userId] = MessageBox.LevelSettings; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.LevelSettings)); }
/// <summary>Called when a change is made to a server. </summary> internal async Task GuildUpdateAsync(SocketGuild oldGuild, SocketGuild newGuild) { foreach (PluginInfo plugin in GlobalConfig.PluginInfo) { if (plugin.MessageReceivedAsync != null) { if (GlobalConfig.RunPluginFunctionsAsynchronously) #pragma warning disable 4014 { plugin.GuildUpdate(oldGuild, newGuild); } #pragma warning restore 4014 else { await plugin.GuildUpdate(oldGuild, newGuild); } } } RavenGuild guild = RavenDb.GetGuild(oldGuild.Id); // Compare changes if (oldGuild.Name != newGuild.Name) { guild.Name = newGuild.Name; } guild.TotalUsers = (uint)newGuild.Users.Count; guild.Save(); }
public async Task ConfigAsync() { RavenGuild guild = RavenDb.GetGuild(Context.Guild.Id); guild.UserConfiguration[Context.User.Id] = MessageBox.BaseMenu; guild.Save(); await ReplyAsync(ConfigHandler.GetCodeBlock(File.ReadAllText($"{Directory.GetCurrentDirectory()}/ConfigTextFiles/{MenuFiles.BaseMenu.ToString()}.txt"))); }
private static Task <RestUserMessage> GeneralSetPrefix(RavenGuild guild, ulong userId, SocketTextChannel channel, string[] args) { if (args.ElementAtOrDefault(1) is null) // If they didn't provide a channel name { return(channel.SendMessageAsync(GetMissingParam("Prefix", typeof(string)))); } guild.GuildSettings.Prefix = string.Join(' ', args.Skip(1)); guild.UserConfiguration[userId] = MessageBox.GeneralSettings; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.GeneralSettings)); }
private static Task <RestUserMessage> BlacklistAddCommand(RavenGuild guild, ulong userId, SocketTextChannel channel, string[] args) { if (args.ElementAtOrDefault(1) is null) { return(channel.SendMessageAsync(GetMissingParam("CommandName", typeof(string)))); } string name = string.Join(' ', args.Skip(1)).ToLower(); guild.GuildSettings.BlacklistedCommands.Add(name); guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.ConfigureDisallowedCommands)); }
private static Task <RestUserMessage> GoodbyePreviewMessage(RavenGuild guild, ulong userId, SocketTextChannel channel, string[] args) { if (string.IsNullOrWhiteSpace(guild.GuildSettings.GoodbyeMessage.Message)) { return(channel.SendMessageAsync("There is currently no message set.")); } Task.Run(async() => { await channel.SendMessageAsync(guild.GuildSettings.GoodbyeMessage.Message .Replace("%SERVER%", channel.Guild.Name) .Replace("%USER%", "Raven")); }); guild.UserConfiguration[userId] = MessageBox.GoodbyeSettings; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.GoodbyeSettings)); }
private static Task <RestUserMessage> GoodbyeSetMessage(RavenGuild guild, ulong userId, SocketTextChannel channel, string[] args) { if (string.IsNullOrWhiteSpace(args.ElementAtOrDefault(1))) { return(channel.SendMessageAsync(GetMissingParam("Message", typeof(string)))); } string input = string.Join(' ', args.Skip(1)); if (input.Length > 1900) { return(channel.SendMessageAsync("You cannot put in a message over 1900 characters. " + "The bot limits this as a saftey net so you don't go to close to Discord's native 2000 character limit.")); } guild.GuildSettings.GoodbyeMessage.Message = input; guild.UserConfiguration[userId] = MessageBox.GoodbyeSettings; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.GoodbyeSettings)); }
private static Task <RestUserMessage> BlacklistAddRole(RavenGuild guild, ulong userId, SocketTextChannel channel, string[] args) { if (args.ElementAtOrDefault(1) is null) // If they didn't provide a role name { return(channel.SendMessageAsync(GetMissingParam("RoleName", typeof(string)))); } var tempRole = channel.Guild.Roles.FirstOrDefault(x => x.Name == string.Join(' ', args.Skip(1))); tempRole = tempRole ?? channel.Guild.Roles.FirstOrDefault(x => x.Name.Contains(string.Join(' ', args.Skip(1)))); if (tempRole is null) // If we found no matching channels { return(channel.SendMessageAsync("The specified role could not be found. Please try again.")); } guild.GuildSettings.BlacklistedRoles.Add(tempRole.Id); guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.ConfigureBlacklistedRoles)); }
private static Task <RestUserMessage> RemoveTag(RavenGuild guild, ulong userId, SocketTextChannel channel, string[] args) { string name = args.ElementAtOrDefault(1); if (name is null) { return(channel.SendMessageAsync(GetMissingParam("TagName", typeof(string)))); } int tagIndex = guild.Tags.FindIndex(x => string.Equals(x.Tag, name, StringComparison.CurrentCultureIgnoreCase)); if (tagIndex is - 1) { return(channel.SendMessageAsync("Specified tag name does not exist.")); } guild.Tags.RemoveAt(tagIndex); guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.TagSettings)); }
private static Task <RestUserMessage> BlacklistRemoveModule(RavenGuild guild, ulong userId, SocketTextChannel channel, string[] args) { if (args.ElementAtOrDefault(1) is null) { return(channel.SendMessageAsync(GetMissingParam("ModuleName", typeof(string)))); } string name = string.Join(' ', args.Skip(1)).ToLower(); if (guild.GuildSettings.BlacklistedModules.Any(x => x == name)) { guild.GuildSettings.BlacklistedModules.Remove(name); guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.ConfigureDisallowedModules)); } else { return(channel.SendMessageAsync("The specified module was not blacklisted.")); } }
private static Task <RestUserMessage> AddTag(RavenGuild guild, ulong userId, SocketTextChannel channel, string[] args) { string name = args.ElementAtOrDefault(1); string category = args.ElementAtOrDefault(2); if (name is null) { return(channel.SendMessageAsync(GetMissingParam("TagName", typeof(string)))); } if (guild.Tags.Any(x => string.Equals(x.Tag, name, StringComparison.CurrentCultureIgnoreCase))) { return(channel.SendMessageAsync("Specified tag name already exists.")); } if (category is null) { return(channel.SendMessageAsync(GetMissingParam("TagCategory", typeof(string)))); } if (args.ElementAtOrDefault(3) is null) { return(channel.SendMessageAsync(GetMissingParam("TagMessage", typeof(string)))); } string message = string.Join(" ", args.Skip(3)); RavenTag tag = new RavenTag { AuthorId = userId, Category = category, Tag = name, Message = message }; guild.Tags.Add(tag); guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.TagSettings)); }
private static Task <RestUserMessage> BlacklistAddUser(RavenGuild guild, ulong userId, SocketTextChannel channel, string[] args) { if (args.ElementAtOrDefault(1) is null) { return(channel.SendMessageAsync(GetMissingParam("Username", typeof(string)))); } string name = string.Join(' ', args.Skip(1)).ToLower(); var user = (channel.Guild.Users.FirstOrDefault(x => (x.Username + "#" + x.DiscriminatorValue).Contains(name)) ?? channel.Guild.Users.FirstOrDefault(x => x.Nickname.Contains(name))) ?? channel.Guild.Users.FirstOrDefault(x => x.Id.ToString() == name); if (user is null) { return(channel.SendMessageAsync("Could not find a matching user.")); } guild.GuildSettings.BlacklistedUsers.Add(user.Id); guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.ConfigureBlacklistedUsers)); }
private static Task <RestUserMessage> LsAddLevelBinding(RavenGuild guild, ulong userId, SocketTextChannel channel, string[] args) { if (args.ElementAtOrDefault(1) is null) { return(channel.SendMessageAsync(GetMissingParam("Level", typeof(byte)))); } if (!byte.TryParse(args.ElementAt(1), out byte val)) { return(channel.SendMessageAsync(ParamWrongFormat("Level", typeof(byte)))); } if (val <= 1) { return(channel.SendMessageAsync("You cannot bind a rank to level 1 or below.")); } if (guild.GuildSettings.LevelConfig.RankBindings.ContainsKey(val)) { return(channel.SendMessageAsync($"Level {val} already has a binding assigned to it.")); } if (string.IsNullOrWhiteSpace(args.ElementAtOrDefault(2))) { return(channel.SendMessageAsync(GetMissingParam("RankName", typeof(string)))); } string value = string.Join(' ', args.Skip(2)); if (value.Length > 32) { return(channel.SendMessageAsync("Rank name cannot be over 32 characters.")); } guild.GuildSettings.LevelConfig.RankBindings[val] = value; guild.UserConfiguration[userId] = MessageBox.LevelSettings; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.LevelSettings)); }
private static Task <RestUserMessage> BlacklistRemoveChannel(RavenGuild guild, ulong userId, SocketTextChannel channel, string[] args) { if (args.ElementAtOrDefault(1) is null) // If they didn't provide a channel name { return(channel.SendMessageAsync(GetMissingParam("ChannelId", typeof(uint)))); } if (!uint.TryParse(args.ElementAtOrDefault(1), out uint id)) { return(channel.SendMessageAsync(ParamWrongFormat("ChannelId", typeof(uint)))); } if (guild.GuildSettings.BlacklistedChannels.Any(x => x == id)) { guild.GuildSettings.BlacklistedChannels.Remove(id); guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.GeneralConfigureBlacklistedChannels)); } else { return(channel.SendMessageAsync("The specified channel was not blacklisted.")); } }
private static Task <RestUserMessage> BlacklistRemoveUser(RavenGuild guild, ulong userId, SocketTextChannel channel, string[] args) { if (args.ElementAtOrDefault(1) is null) { return(channel.SendMessageAsync(GetMissingParam("UserId", typeof(ulong)))); } if (!ulong.TryParse(args.ElementAtOrDefault(1), out ulong id)) { return(channel.SendMessageAsync(ParamWrongFormat("UserId", typeof(ulong)))); } if (guild.GuildSettings.BlacklistedUsers.Any(x => x == id)) { guild.GuildSettings.BlacklistedUsers.Remove(id); guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.ConfigureBlacklistedUsers)); } else { return(channel.SendMessageAsync("The specified user was not blacklisted.")); } }
/// <summary>Select a new menu option to jump to.</summary> public static Task <RestUserMessage> SelectSubMenu(RavenGuild guild, ulong userId, SocketTextChannel channel, MessageBox option) { switch (option) { case MessageBox.BaseMenu: { guild.UserConfiguration[userId] = MessageBox.BaseMenu; guild.Save(); return(channel.SendMessageAsync(GetCodeBlock(File.ReadAllText( $"{Directory.GetCurrentDirectory()}/ConfigTextFiles/{MenuFiles.BaseMenu.ToString()}.txt")))); } case MessageBox.LevelSettings: { guild.UserConfiguration[userId] = MessageBox.LevelSettings; guild.Save(); return(channel.SendMessageAsync(GetCodeBlock( File.ReadAllText( $@"{Directory.GetCurrentDirectory()}/ConfigTextFiles/{MenuFiles.LevelSettings}.txt")) .Replace("%MinXP%", guild.GuildSettings.LevelConfig.MinXpGenerated.ToString()) .Replace("%MaxXP%", guild.GuildSettings.LevelConfig.MaxXpGenerated.ToString()) .Replace("%XPTime%", guild.GuildSettings.LevelConfig.SecondsBetweenXpGiven.ToString()))); } case MessageBox.WelcomeSettings: { guild.UserConfiguration[userId] = MessageBox.WelcomeSettings; guild.Save(); return(channel.SendMessageAsync(GetCodeBlock( File.ReadAllText( $@"{Directory.GetCurrentDirectory()}/ConfigTextFiles/{MenuFiles.WelcomeSettings}.txt")) .Replace("%state%", guild.GuildSettings.WelcomeMessage.Enabled ? "Enabled" : "Disabled") .Replace("%channel%", guild.GuildSettings.WelcomeMessage.ChannelId == null ? "Not Set" : channel.Guild.GetTextChannel(guild.GuildSettings.WelcomeMessage.ChannelId.Value) == null ? "DELETED CHANNEL" : "#" + channel.Guild.GetTextChannel(guild.GuildSettings.WelcomeMessage.ChannelId.Value) .Name))); } case MessageBox.GoodbyeSettings: { guild.UserConfiguration[userId] = MessageBox.GoodbyeSettings; guild.Save(); return(channel.SendMessageAsync(GetCodeBlock( File.ReadAllText( $@"{Directory.GetCurrentDirectory()}/ConfigTextFiles/{MenuFiles.GoodbyeSettings}.txt")) .Replace("%state%", guild.GuildSettings.GoodbyeMessage.Enabled ? "Enabled" : "Disabled") .Replace("%channel%", guild.GuildSettings.GoodbyeMessage.ChannelId == null ? "Not Set" : channel.Guild.GetTextChannel(guild.GuildSettings.GoodbyeMessage.ChannelId.Value) == null ? "DELETED CHANNEL" : "#" + channel.Guild.GetTextChannel(guild.GuildSettings.GoodbyeMessage.ChannelId.Value) .Name))); } case MessageBox.LoggingSettings: { guild.UserConfiguration[userId] = MessageBox.LoggingSettings; guild.Save(); return(channel.SendMessageAsync(GetCodeBlock( File.ReadAllText( $@"{Directory.GetCurrentDirectory()}/ConfigTextFiles/{MenuFiles.LoggingSettings}.txt")) .Replace("%state%", guild.LoggingSettings.Enabled ? "Enabled" : "Disabled") .Replace("%join%", guild.LoggingSettings.Join ? "Enabled" : "Disabled") .Replace("%leave%", guild.LoggingSettings.Leave ? "Enabled" : "Disabled") .Replace("%ban%", guild.LoggingSettings.Ban ? "Enabled" : "Disabled") .Replace("%msg%", guild.LoggingSettings.Msg ? "Enabled" : "Disabled") .Replace("%user%", guild.LoggingSettings.User ? "Enabled" : "Disabled") .Replace("%role%", guild.LoggingSettings.Role ? "Enabled" : "Disabled") .Replace("%vc%", guild.LoggingSettings.VoiceChannel ? "Enabled" : "Disabled") .Replace("%guild%", guild.LoggingSettings.Join ? "Enabled" : "Disabled") .Replace("%channel%", guild.LoggingSettings.ChannelId == null ? "Not Set" : channel.Guild.GetTextChannel(guild.LoggingSettings.ChannelId.Value) == null ? "DELETED CHANNEL" : "#" + channel.Guild.GetTextChannel(guild.LoggingSettings.ChannelId.Value) .Name))); } case MessageBox.GeneralSettings: { guild.UserConfiguration[userId] = MessageBox.GeneralSettings; guild.Save(); return(channel.SendMessageAsync(GetCodeBlock( File.ReadAllText( $@"{Directory.GetCurrentDirectory()}/ConfigTextFiles/{MenuFiles.GeneralSettings}.txt")) .Replace("%prefix%", guild.GuildSettings.Prefix) .Replace("%invite%", guild.GuildSettings.AutoblockInviteLinks ? "Enabled" : "Disabled"))); } // Sub menus case MessageBox.LsSettingSubmenu: { guild.UserConfiguration[userId] = MessageBox.LsSettingSubmenu; guild.Save(); return(channel.SendMessageAsync(GetCodeBlock( File.ReadAllText( $@"{Directory.GetCurrentDirectory()}/ConfigTextFiles/{MenuFiles.LsSubSettings}.txt")) .Replace("%CurrentSetting%", SplitPascalCase(guild.GuildSettings.LevelConfig.LevelSettings.ToString())))); } default: guild.UserConfiguration.Remove(userId); guild.Save(); return(channel.SendMessageAsync("I don't know how you got here, but I'm going to termiante this menu just in case.")); } }
/// <summary>Called when a user joins the server. </summary> internal async Task GuildUserJoinAsync(SocketGuildUser user) { foreach (PluginInfo plugin in GlobalConfig.PluginInfo) { if (plugin.MessageReceivedAsync != null) { if (GlobalConfig.RunPluginFunctionsAsynchronously) #pragma warning disable 4014 { plugin.GuildUserLeave.Invoke(user); } #pragma warning restore 4014 else { await plugin.GuildUserLeave(user); } } } // Add it to the global database if they don't exist if (RavenDb.GetUser(user.Id) is null) { RavenDb.CreateNewUser(user.Id, user.Username, user.DiscriminatorValue, user.GetAvatarUrl() ?? user.GetDefaultAvatarUrl()); } // Get the guild this user is in RavenGuild guild = RavenDb.GetGuild(user.Guild.Id) ?? RavenDb.CreateNewGuild(user.Guild.Id, user.Guild.Name); // Update the total amount of users guild.TotalUsers = (uint)user.Guild.Users.Count; // If they rejoined, we'll store their old name to log bool rejoined = false; string username = string.Empty; // Get the user from that guild RavenUser guildUser = guild.GetUser(user.Id); if (guildUser is null) // if they don't exist, we'll need to create them { guild.CreateNewUser(user.Id, user.Username, user.DiscriminatorValue, user.GetAvatarUrl() ?? user.GetDefaultAvatarUrl()); } else { // They rejoined, update their name in case/discrim in case it changed rejoined = true; username = guildUser.Username + "#" + guildUser.Discriminator; guildUser.Username = user.Username; guildUser.Discriminator = user.DiscriminatorValue; guild.Save(); // Save the updated information, while storing the old one for logging purposes } // Process welcome message if one is set if (guild.GuildSettings.WelcomeMessage.Enabled) { // If the targeted channel is null or no longer exists or the message itself is undefined if (guild.GuildSettings.WelcomeMessage.ChannelId is null || user.Guild.GetTextChannel(guild.GuildSettings.WelcomeMessage.ChannelId.GetValueOrDefault()) is null || string.IsNullOrWhiteSpace(guild.GuildSettings.WelcomeMessage.Message)) { // If the logging channel is setup, exists, and is enabled if (!(guild.LoggingSettings.ChannelId is null) && !(user.Guild.GetTextChannel(guild.LoggingSettings.ChannelId.GetValueOrDefault()) is null) && guild.LoggingSettings.Enabled) { // Log to the logging channel if it has been set await user.Guild.GetTextChannel(guild.LoggingSettings.ChannelId.Value).SendMessageAsync(null, false, new EmbedBuilder() { Title = "Warning!", Color = new Color(255, 128, 0), // Orange Description = "Unable to send welcome message. Channel or message are currently null. Please reconfigure it.", Footer = new EmbedFooterBuilder() { Text = $"{DateTime.UtcNow:ddd MMM d yyyy HH mm}" } }.Build()); } } else { // Send the welcome message and repalce the server or user tags if they are present await user.Guild.GetTextChannel(guild.GuildSettings.WelcomeMessage.ChannelId.Value) .SendMessageAsync(guild.GuildSettings.WelcomeMessage.Message .Replace("%SERVER%", user.Guild.Name) .Replace("%USER%", user.Username)); } }
/// <summary>Process the actual options</summary> public static Task <RestUserMessage> SelectOption(RavenGuild guild, ulong userId, SocketTextChannel channel, string[] args) { if (!uint.TryParse(args[0], out uint temp)) { return(InvalidOption(channel)); } MessageBox option = (MessageBox)temp; switch (guild.UserConfiguration[userId]) { // Don't know how this would be possible, but better safe than sorry. case MessageBox.BaseMenu: return(SelectSubMenu(guild, userId, channel, option)); // Level Settings Sub Menu case MessageBox.LevelSettings: { if ((int)option is 7) // We need to cast our submenus to a higher value otherwise they cause problems when selecting options { option = MessageBox.LsSettingSubmenu; } switch (option) { case MessageBox.LsSetMinXp: return(LsSetMinXp(guild, userId, channel, args)); case MessageBox.LsSetMaxXp: return(LsSetMaxXp(guild, userId, channel, args)); case MessageBox.LsSetXpTime: return(LsSetMinXpTime(guild, userId, channel, args)); case MessageBox.LsAddLevelBinding: return(LsAddLevelBinding(guild, userId, channel, args)); case MessageBox.LsRemoveLevelBinding: return(LsRemoveLevelBinding(guild, userId, channel, args)); case MessageBox.LsListLevelBindings: return(LsListLevelBindings(guild, userId, channel, args)); case MessageBox.LsSettingSubmenu: return(SelectSubMenu(guild, userId, channel, option)); default: return(InvalidOption(channel)); } } // Level Settings Sub-Sub Menu case MessageBox.LsSettingSubmenu: { switch (option) { case MessageBox.LsSettingDisabled: return(LsSetLevelState(guild, userId, channel, LevelSettings.Disabled)); case MessageBox.LsSettingGlobalLevel: return(LsSetLevelState(guild, userId, channel, LevelSettings.GlobalLeveling)); case MessageBox.LsSettingGuildLevel: return(LsSetLevelState(guild, userId, channel, LevelSettings.GuildLeveling)); default: return(InvalidOption(channel)); } } // Welcome Message Settings Sub Menu case MessageBox.WelcomeSettings: { switch (option) { case MessageBox.WelcomeToggle: guild.GuildSettings.WelcomeMessage.Enabled = !guild.GuildSettings.WelcomeMessage.Enabled; guild.UserConfiguration[userId] = MessageBox.WelcomeSettings; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.WelcomeSettings)); case MessageBox.WelcomeChannel: return(WelcomeSetChannel(guild, userId, channel, args)); case MessageBox.WelcomeMessage: return(WelcomeSetMessage(guild, userId, channel, args)); case MessageBox.WelcomePreview: return(WelcomePreviewMessage(guild, userId, channel, args)); default: return(InvalidOption(channel)); } } // Goodbye Settings Submenu case MessageBox.GoodbyeSettings: { switch (option) { case MessageBox.GoodbyeToggle: guild.GuildSettings.GoodbyeMessage.Enabled = !guild.GuildSettings.GoodbyeMessage.Enabled; guild.UserConfiguration[userId] = MessageBox.GoodbyeSettings; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.GoodbyeSettings)); case MessageBox.GoodbyeChannel: return(GoodbyeSetChannel(guild, userId, channel, args)); case MessageBox.GoodbyeMessage: return(GoodbyeSetMessage(guild, userId, channel, args)); case MessageBox.GoodbyePreview: return(GoodbyePreviewMessage(guild, userId, channel, args)); default: return(InvalidOption(channel)); } } // Welcome Message Settings Sub Menu case MessageBox.LoggingSettings: { switch (option) { case MessageBox.LoggingModuleEnabled: guild.LoggingSettings.Enabled = !guild.LoggingSettings.Enabled; guild.UserConfiguration[userId] = MessageBox.LoggingSettings; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.LoggingSettings)); case MessageBox.LoggingChannel: return(LoggingSetChannel(guild, userId, channel, args)); case MessageBox.LoggingEnableAll: guild.LoggingSettings.Enabled = true; guild.LoggingSettings.Join = true; guild.LoggingSettings.Leave = true; guild.LoggingSettings.Ban = true; guild.LoggingSettings.Msg = true; guild.LoggingSettings.User = true; guild.LoggingSettings.VoiceChannel = true; guild.LoggingSettings.Role = true; guild.LoggingSettings.GuildUpdate = true; guild.UserConfiguration[userId] = MessageBox.LoggingSettings; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.LoggingSettings)); case MessageBox.LoggingDisableAll: guild.LoggingSettings.Enabled = false; guild.LoggingSettings.Join = false; guild.LoggingSettings.Leave = false; guild.LoggingSettings.Ban = false; guild.LoggingSettings.Msg = false; guild.LoggingSettings.User = false; guild.LoggingSettings.VoiceChannel = false; guild.LoggingSettings.Role = false; guild.LoggingSettings.GuildUpdate = false; guild.UserConfiguration[userId] = MessageBox.LoggingSettings; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.LoggingSettings)); case MessageBox.LoggingJoin: guild.LoggingSettings.Join = !guild.LoggingSettings.Join; guild.UserConfiguration[userId] = MessageBox.LoggingSettings; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.LoggingSettings)); case MessageBox.LoggingLeave: guild.LoggingSettings.Leave = !guild.LoggingSettings.Leave; guild.UserConfiguration[userId] = MessageBox.LoggingSettings; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.LoggingSettings)); case MessageBox.LoggingBan: guild.LoggingSettings.Ban = !guild.LoggingSettings.Ban; guild.UserConfiguration[userId] = MessageBox.LoggingSettings; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.LoggingSettings)); case MessageBox.LoggingMsg: guild.LoggingSettings.Msg = !guild.LoggingSettings.Msg; guild.UserConfiguration[userId] = MessageBox.LoggingSettings; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.LoggingSettings)); case MessageBox.LoggingUser: guild.LoggingSettings.User = !guild.LoggingSettings.User; guild.UserConfiguration[userId] = MessageBox.LoggingSettings; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.LoggingSettings)); case MessageBox.LoggingRole: guild.LoggingSettings.Role = !guild.LoggingSettings.Role; guild.UserConfiguration[userId] = MessageBox.LoggingSettings; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.LoggingSettings)); case MessageBox.LoggingVc: guild.LoggingSettings.VoiceChannel = !guild.LoggingSettings.VoiceChannel; guild.UserConfiguration[userId] = MessageBox.LoggingSettings; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.LoggingSettings)); case MessageBox.LoggingGuildUpdate: guild.LoggingSettings.GuildUpdate = !guild.LoggingSettings.GuildUpdate; guild.UserConfiguration[userId] = MessageBox.LoggingSettings; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.LoggingSettings)); default: return(InvalidOption(channel)); } } // Generic Settings (prefix, blacklists, module control, and probably more in the future) case MessageBox.GeneralSettings: { switch (option) { case MessageBox.GeneralSetPrefix: return(GeneralSetPrefix(guild, userId, channel, args)); case MessageBox.GeneralToggleInviteBlocking: guild.GuildSettings.AutoblockInviteLinks = !guild.GuildSettings.AutoblockInviteLinks; guild.UserConfiguration[userId] = MessageBox.GeneralSettings; guild.Save(); return(SelectSubMenu(guild, userId, channel, MessageBox.GeneralSettings)); default: return(InvalidOption(channel)); } } // Tag Settings Sub Menu case MessageBox.TagSettings: { switch (option) { case MessageBox.TagAdd: return(AddTag(guild, userId, channel, args)); case MessageBox.TagRemove: return(RemoveTag(guild, userId, channel, args)); default: return(InvalidOption(channel)); } } case MessageBox.BlacklistSettings: { switch ((int)option) { case 1: option = MessageBox.ConfigureDisallowedModules; break; case 2: option = MessageBox.ConfigureDisallowedCommands; break; case 3: option = MessageBox.ConfigureBlacklistedChannels; break; case 4: option = MessageBox.ConfigureBlacklistedRoles; break; case 5: option = MessageBox.ConfigureBlacklistedUsers; break; } switch (option) { case MessageBox.ConfigureDisallowedModules: case MessageBox.ConfigureDisallowedCommands: case MessageBox.ConfigureBlacklistedChannels: case MessageBox.ConfigureBlacklistedRoles: case MessageBox.ConfigureBlacklistedUsers: return(SelectSubMenu(guild, userId, channel, option)); default: return(InvalidOption(channel)); } } case MessageBox.ConfigureDisallowedModules: { switch (option) { case MessageBox.BlacklistAddTo: return(BlacklistAddModule(guild, userId, channel, args)); case MessageBox.BlacklistRemoveFrom: return(BlacklistRemoveModule(guild, userId, channel, args)); case MessageBox.BlacklistDisplay: return(BlacklistDisplayModules(guild, channel)); default: return(InvalidOption(channel)); } } case MessageBox.ConfigureDisallowedCommands: { switch (option) { case MessageBox.BlacklistAddTo: return(BlacklistAddCommand(guild, userId, channel, args)); case MessageBox.BlacklistRemoveFrom: return(BlacklistRemoveCommand(guild, userId, channel, args)); case MessageBox.BlacklistDisplay: return(BlacklistDisplayCommands(guild, channel)); default: return(InvalidOption(channel)); } } case MessageBox.ConfigureBlacklistedChannels: { switch (option) { case MessageBox.BlacklistAddTo: return(BlacklistAddChannel(guild, userId, channel, args)); case MessageBox.BlacklistRemoveFrom: return(BlacklistRemoveChannel(guild, userId, channel, args)); case MessageBox.BlacklistDisplay: return(BlacklistDisplayChannels(guild, userId, channel, args)); default: return(InvalidOption(channel)); } } case MessageBox.ConfigureBlacklistedRoles: { switch (option) { case MessageBox.BlacklistAddTo: return(BlacklistAddRole(guild, userId, channel, args)); case MessageBox.BlacklistRemoveFrom: return(BlacklistRemoveRole(guild, userId, channel, args)); case MessageBox.BlacklistDisplay: return(BlacklistDisplayRoles(guild, userId, channel, args)); default: return(InvalidOption(channel)); } } case MessageBox.ConfigureBlacklistedUsers: { switch (option) { case MessageBox.BlacklistAddTo: return(BlacklistAddUser(guild, userId, channel, args)); case MessageBox.BlacklistRemoveFrom: return(BlacklistRemoveUser(guild, userId, channel, args)); case MessageBox.BlacklistDisplay: return(BlacklistDisplayUsers(guild, userId, channel, args)); default: return(InvalidOption(channel)); } } default: guild.UserConfiguration.Remove(userId); guild.Save(); return(channel.SendMessageAsync("I don't know how you got here, but I am gonna exit the menu just to be safe.\n" + "(You should probably report this if it's reproducible.)")); } }