mirror of
https://github.com/RPCS3/discord-bot.git
synced 2024-11-23 10:19:39 +00:00
Merge pull request #933 from 13xforever/vnext
fix !filters add without argument
This commit is contained in:
commit
0dbd833838
@ -99,21 +99,25 @@ internal sealed class ContentFilters: BaseCommandModuleCustom
|
|||||||
|
|
||||||
[Command("add"), Aliases("create")]
|
[Command("add"), Aliases("create")]
|
||||||
[Description("Adds a new content filter")]
|
[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();
|
await using var db = new BotDb();
|
||||||
Piracystring? filter;
|
Piracystring? filter;
|
||||||
|
var isNewFilter = true;
|
||||||
if (string.IsNullOrEmpty(trigger))
|
if (string.IsNullOrEmpty(trigger))
|
||||||
filter = new Piracystring();
|
filter = new() {String = trigger};
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
filter = await db.Piracystring.FirstOrDefaultAsync(ps => ps.String == trigger && ps.Disabled).ConfigureAwait(false);
|
filter = await db.Piracystring.FirstOrDefaultAsync(ps => ps.String == trigger && ps.Disabled).ConfigureAwait(false);
|
||||||
if (filter == null)
|
if (filter == null)
|
||||||
filter = new Piracystring {String = trigger};
|
filter = new() {String = trigger};
|
||||||
else
|
else
|
||||||
|
{
|
||||||
filter.Disabled = false;
|
filter.Disabled = false;
|
||||||
|
isNewFilter = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var isNewFilter = filter.Id == default;
|
|
||||||
if (isNewFilter)
|
if (isNewFilter)
|
||||||
{
|
{
|
||||||
filter.Context = FilterContext.Chat | FilterContext.Log;
|
filter.Context = FilterContext.Chat | FilterContext.Log;
|
||||||
|
Loading…
Reference in New Issue
Block a user