mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-12 02:08:27 -04:00
dev: .qid cleaned up
This commit is contained in:
@@ -106,13 +106,7 @@ public partial class Utility
|
|||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task QuoteShow(kwum quoteId)
|
public async Task QuoteShow(kwum quoteId)
|
||||||
{
|
{
|
||||||
Quote? quote;
|
var quote = await _service.GetQuoteByIdAsync(ctx.Guild.Id, quoteId);
|
||||||
await using (var uow = _db.GetDbContext())
|
|
||||||
{
|
|
||||||
quote = uow.Set<Quote>().GetById(quoteId);
|
|
||||||
if (quote?.GuildId != ctx.Guild.Id)
|
|
||||||
quote = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (quote is null)
|
if (quote is null)
|
||||||
{
|
{
|
||||||
@@ -224,9 +218,9 @@ public partial class Utility
|
|||||||
if (quoteId < 0)
|
if (quoteId < 0)
|
||||||
return;
|
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();
|
await Response().Error(strs.quotes_notfound).SendAsync();
|
||||||
return;
|
return;
|
||||||
|
@@ -118,9 +118,14 @@ public sealed class QuoteService : IQuoteService, INService
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Quote> GetQuoteByIdAsync(kwum quoteId)
|
public async Task<Quote?> GetQuoteByIdAsync(ulong guildId, kwum quoteId)
|
||||||
{
|
{
|
||||||
await using var uow = _db.GetDbContext();
|
await using var uow = _db.GetDbContext();
|
||||||
return uow.Set<Quote>().GetById(quoteId);
|
|
||||||
|
var quote = await uow.GetTable<Quote>()
|
||||||
|
.Where(x => x.Id == quoteId && x.GuildId == guildId)
|
||||||
|
.FirstOrDefaultAsyncLinqToDB();
|
||||||
|
|
||||||
|
return quote;
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user