public async Task AddAsync(CommandContext ctx, [RemainingText] string pattern) { Censor censor = new Censor { Pattern = pattern, }; this.db.Censors.Add(censor); await this.db.SaveChangesAsync(); this.censorer.AddCensor(censor); await ctx.Message.CreateReactionAsync(DiscordEmoji.FromName(ctx.Client, ":white_check_mark:")); }
public async Task RemoveAsync(CommandContext ctx, int id) { Censor censor = await this.db.Censors .Where(c => c.Id == id) .FirstOrDefaultAsync(); if (censor == null) { await ctx.Message.CreateReactionAsync(DiscordEmoji.FromName(ctx.Client, ":interrobang:")); return; } this.db.Censors.Remove(censor); await this.db.SaveChangesAsync(); this.censorer.RemoveCensor(censor.Id); await ctx.Message.CreateReactionAsync(DiscordEmoji.FromName(ctx.Client, ":white_check_mark:")); }
public void AddCensor(Censor censor) { this.censorRegexes.Add(censor.Id, new Regex(ToRegexPattern(censor.Pattern), RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)); }