mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 01:38:27 -04:00
Fixed an issue with expression settings toggle, closes #353
This commit is contained in:
@@ -241,7 +241,7 @@ public partial class NadekoExpressions : NadekoModule<NadekoExpressionsService>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var (success, newVal) = await _service.ToggleExprOptionAsync(id, option);
|
var (success, newVal) = await _service.ToggleExprOptionAsync(ctx.Guild?.Id, id, option);
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync(strs.expr_no_found_id);
|
await ReplyErrorLocalizedAsync(strs.expr_no_found_id);
|
||||||
|
@@ -448,14 +448,15 @@ public sealed class NadekoExpressionsService : IEarlyBehavior, IReadyExecutor
|
|||||||
await UpdateInternalAsync(guildId, expr);
|
await UpdateInternalAsync(guildId, expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(bool Sucess, bool NewValue)> ToggleExprOptionAsync(int id, ExprField field)
|
public async Task<(bool Sucess, bool NewValue)> ToggleExprOptionAsync(ulong? guildId, int id, ExprField field)
|
||||||
{
|
{
|
||||||
var newVal = false;
|
var newVal = false;
|
||||||
NadekoExpression expr;
|
NadekoExpression expr;
|
||||||
await using (var uow = _db.GetDbContext())
|
await using (var uow = _db.GetDbContext())
|
||||||
{
|
{
|
||||||
expr = uow.Expressions.GetById(id);
|
expr = uow.Expressions.GetById(id);
|
||||||
if (expr is null)
|
|
||||||
|
if (expr is null || expr.GuildId != guildId)
|
||||||
return (false, false);
|
return (false, false);
|
||||||
if (field == ExprField.AutoDelete)
|
if (field == ExprField.AutoDelete)
|
||||||
newVal = expr.AutoDeleteTrigger = !expr.AutoDeleteTrigger;
|
newVal = expr.AutoDeleteTrigger = !expr.AutoDeleteTrigger;
|
||||||
@@ -469,7 +470,7 @@ public sealed class NadekoExpressionsService : IEarlyBehavior, IReadyExecutor
|
|||||||
await uow.SaveChangesAsync();
|
await uow.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
await UpdateInternalAsync(expr.GuildId, expr);
|
await UpdateInternalAsync(guildId, expr);
|
||||||
|
|
||||||
return (true, newVal);
|
return (true, newVal);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user