fix !filters add without argument

probably broke with d#+ update
This commit is contained in:
13xforever 2023-05-06 03:39:33 +05:00
parent 5bf1090cb0
commit 42a3a6a017
No known key found for this signature in database
GPG Key ID: 2B2A36B482FE70C5

View File

@ -99,21 +99,25 @@ internal sealed class ContentFilters: BaseCommandModuleCustom
[Command("add"), Aliases("create")]
[Description("Adds a new content filter")]
public async Task Add(CommandContext ctx, [RemainingText, Description("A plain string to match")] string trigger)
public async Task Add(CommandContext ctx, [RemainingText, Description("A plain string to match")] string? trigger)
{
trigger ??= "";
await using var db = new BotDb();
Piracystring? filter;
var isNewFilter = true;
if (string.IsNullOrEmpty(trigger))
filter = new Piracystring();
filter = new() {String = trigger};
else
{
filter = await db.Piracystring.FirstOrDefaultAsync(ps => ps.String == trigger && ps.Disabled).ConfigureAwait(false);
if (filter == null)
filter = new Piracystring {String = trigger};
filter = new() {String = trigger};
else
{
filter.Disabled = false;
isNewFilter = false;
}
}
var isNewFilter = filter.Id == default;
if (isNewFilter)
{
filter.Context = FilterContext.Chat | FilterContext.Log;