mirror of
				https://gitlab.com/Kwoth/nadekobot.git
				synced 2025-11-04 00:34:26 -05:00 
			
		
		
		
	dev: .qid cleaned up
This commit is contained in:
		@@ -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<Quote>().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;
 | 
			
		||||
 
 | 
			
		||||
@@ -118,9 +118,14 @@ public sealed class QuoteService : IQuoteService, INService
 | 
			
		||||
        return count;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public async Task<Quote> GetQuoteByIdAsync(kwum quoteId)
 | 
			
		||||
    public async Task<Quote?> GetQuoteByIdAsync(ulong guildId, kwum quoteId)
 | 
			
		||||
    {
 | 
			
		||||
        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