diff --git a/src/NadekoBot/Modules/Utility/Quote/QuoteCommands.cs b/src/NadekoBot/Modules/Utility/Quote/QuoteCommands.cs index c7cd6f296..4625b415b 100644 --- a/src/NadekoBot/Modules/Utility/Quote/QuoteCommands.cs +++ b/src/NadekoBot/Modules/Utility/Quote/QuoteCommands.cs @@ -106,13 +106,7 @@ public partial class Utility [RequireContext(ContextType.Guild)] public async Task QuoteShow(kwum quoteId) { - Quote? quote; - await using (var uow = _db.GetDbContext()) - { - quote = uow.Set().GetById(quoteId); - if (quote?.GuildId != ctx.Guild.Id) - quote = null; - } + var quote = await _service.GetQuoteByIdAsync(ctx.Guild.Id, quoteId); if (quote is null) { @@ -224,9 +218,9 @@ public partial class Utility if (quoteId < 0) return; - var quote = await _service.GetQuoteByIdAsync(quoteId); + var quote = await _service.GetQuoteByIdAsync(ctx.Guild.Id, quoteId); - if (quote is null || quote.GuildId != ctx.Guild.Id) + if (quote is null) { await Response().Error(strs.quotes_notfound).SendAsync(); return; diff --git a/src/NadekoBot/Modules/Utility/Quote/QuoteService.cs b/src/NadekoBot/Modules/Utility/Quote/QuoteService.cs index aa2406a36..325c6b3e2 100644 --- a/src/NadekoBot/Modules/Utility/Quote/QuoteService.cs +++ b/src/NadekoBot/Modules/Utility/Quote/QuoteService.cs @@ -118,9 +118,14 @@ public sealed class QuoteService : IQuoteService, INService return count; } - public async Task GetQuoteByIdAsync(kwum quoteId) + public async Task GetQuoteByIdAsync(ulong guildId, kwum quoteId) { await using var uow = _db.GetDbContext(); - return uow.Set().GetById(quoteId); + + var quote = await uow.GetTable() + .Where(x => x.Id == quoteId && x.GuildId == guildId) + .FirstOrDefaultAsyncLinqToDB(); + + return quote; } } \ No newline at end of file