public static async Task CheckMessageAsync(SocketMessage message) { IndividualConfig config = BotConfig.Load().GetConfig((message.Channel as IGuildChannel).GuildId); if (!config.Censor) { return; } if (message.Content.Length > 0) { string messageText = message.Content.ToLower(); foreach (string word in config.CensoredWords) { if (messageText.Contains(word)) { await message.Author.SendMessageAsync("Your message was deleted as it contained censored words."); if (config.LogActions) { var logChannel = await(message.Channel as IGuildChannel).Guild.GetTextChannelAsync(config.LogChannel); await logChannel.SendMessageAsync($"**Message deleted for profanity.**\nMessage from {message.Author.Mention} was deleted for containing the word '{word}'."); } await message.DeleteAsync(); return; } } } }
private async Task CheckConfigsAsync() { BotConfig conf = BotConfig.Load(); if (configType == ConfigType.Individual) { foreach (var guild in GetBot().Guilds) { IndividualConfig gconf = conf.GetConfig(guild.Id); if (gconf == null) { gconf = conf.FreshConfig(guild.Id); conf.Configs.Add(gconf); } } } await Util.LoggerAsync(new LogMessage(LogSeverity.Info, "Gateway", $"Successfully connected to {bot.Guilds.Count} guilds")); conf.LastStartup = DateTime.UtcNow; conf.Save(); var restart = Task.Run(async() => { await Task.Delay(RestartEveryMs); // Code to restart bot Process.Start(AppContext.BaseDirectory + ExecutableName + ".exe"); // Close this instance Environment.Exit(0); }); }
private async Task SnakesAsync(IUser user = null) { await Context.Message.DeleteAsync(); BotConfig conf = BotConfig.Load(); IndividualConfig gconf = conf.GetConfig(Context.Guild.Id); await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Unimplemented Game", $"This game has not yet been reimplemented into Lori's Angel v2. Try again in a couple days!\n `{gconf.Prefix}changelog` for more information", false); }
private async Task JoinGuildAsync(SocketGuild guild) { if (configType == ConfigType.Individual) { BotConfig conf = BotConfig.Load(); IndividualConfig gconf = conf.GetConfig(guild.Id); if (gconf == null) { gconf = conf.FreshConfig(guild.Id); conf.Configs.Add(gconf); conf.Save(); } } }
private async Task CreateLogAsync(IndividualConfig gconf, EmbedBuilder embed) { if (gconf.LogActions && gconf.LogChannel != 0L) { var logs = await Context.Guild.GetTextChannelAsync(gconf.LogChannel); if (logs != null) { await logs.SendMessageAsync(null, false, embed.Build()); } else { await MessageUtil.SendErrorAsync((Context.Channel as ITextChannel), "Log Channel Error", $"The log channel for this guild could not be found. Make sure the logging settings are set correctly on the webpanel.", false); } } await Context.Channel.SendMessageAsync(null, false, embed.Build()); }
public static void ToggleCommandLogs(ulong guild = 0L, ulong channel = 0L) { BotConfig conf = BotConfig.Load(); if (conf.Type == ConfigType.Solo || guild == 0L) { conf.SoloConfig.LogCommands = !conf.SoloConfig.LogCommands; if (conf.SoloConfig.LogCommands && channel != 0L) { conf.SoloConfig.LogChannel = channel; } } else { IndividualConfig gconf = conf.GetConfig(guild); gconf.LogCommands = !gconf.LogCommands; if (gconf.LogCommands && channel != 0L) { gconf.LogChannel = channel; } } conf.Save(); }
public static EmbedBuilder GetCommandHelp(ulong guildId, string c = null, int page = 1) { BotConfig conf = BotConfig.Load(); IndividualConfig gconf = conf.GetConfig(guildId); List <BotCommand> commands = conf.Commands; int pages; CommandCategory category = CommandCategory.Main; if (c != null) { c = c.ToLower().Trim(); switch (c) { case "fun": category = CommandCategory.Fun; break; case "user": category = CommandCategory.User; break; case "server": category = CommandCategory.Server; break; case "botrelated": category = CommandCategory.BotRelated; break; case "moderation": category = CommandCategory.Moderation; break; case "games": category = CommandCategory.Games; break; case "nsfw": category = CommandCategory.NSFW; break; case "currency": category = CommandCategory.Currency; break; default: category = CommandCategory.Main; break; } } List <CommandCategory> cats = new List <CommandCategory>(); List <BotCommand> commandsToShow = new List <BotCommand>(); bool displayCommandInfo = false; BotCommand commandToDisplay = null; foreach (BotCommand command in commands) { if (c != null) { if (command.Handle.ToLower() == c.ToLower().Trim()) { commandToDisplay = command; displayCommandInfo = true; break; } } if (category == CommandCategory.Main) { if (!cats.Contains(command.Category)) { cats.Add(command.Category); } } if (command.Category == category) { if (!commandsToShow.Contains(command)) { commandsToShow.Add(command); } } } EmbedBuilder embed; if (!displayCommandInfo) { if (category == CommandCategory.Main) { pages = (cats.Count / 10); } else { pages = (commandsToShow.Count / 8); } if (page > pages) { page = pages; } embed = new EmbedBuilder() { Title = "Help: " + StringUtil.ToUppercaseFirst(category.ToString()), Color = Color.DarkPurple, Footer = new EmbedFooterBuilder() { Text = $"{EmojiUtil.GetRandomEmoji()} Server Prefix: {gconf.Prefix}" } }; if (category == CommandCategory.Main) { embed.Description = $"For further help use `{gconf.Prefix}help <commandCategory>`, for example `{gconf.Prefix}help fun`"; foreach (var cat in cats) { embed.AddField(new EmbedFieldBuilder() { Name = StringUtil.ToUppercaseFirst(cat.ToString()), Value = "category description", IsInline = true }); } } else { embed.Description = $"For further help use `{gconf.Prefix}help <commandName>`, for example `{gconf.Prefix}help roast`"; foreach (var command in commandsToShow) { embed.AddField(new EmbedFieldBuilder() { Name = StringUtil.ToUppercaseFirst(command.Handle), Value = command.Description, IsInline = true }); } } } else { embed = new EmbedBuilder() { Title = "Help: " + StringUtil.ToUppercaseFirst(commandToDisplay.Handle), Color = Color.DarkPurple, Footer = new EmbedFooterBuilder() { Text = $"{EmojiUtil.GetRandomEmoji()} <> - Required argument, [] - Optional argument" } }; string desc = $"{commandToDisplay.Description}\n\n**Usage:**"; foreach (var usage in commandToDisplay.Usage) { desc += $"\n**{gconf.Prefix}{usage.ToString()}** (eg. {gconf.Prefix}{usage.ToExample()})"; } embed.Description = desc; } return(embed); }