From d2c7563c5cb655f01fe52314b129132f052a1a02 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sat, 18 May 2024 22:47:25 +0000 Subject: [PATCH] change: Quotes will now use easier to write, alphanumerical ids (same as expressions) --- .../Modules/Utility/Quote/QuoteCommands.cs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/NadekoBot/Modules/Utility/Quote/QuoteCommands.cs b/src/NadekoBot/Modules/Utility/Quote/QuoteCommands.cs index 8095268a1..97cf2b591 100644 --- a/src/NadekoBot/Modules/Utility/Quote/QuoteCommands.cs +++ b/src/NadekoBot/Modules/Utility/Quote/QuoteCommands.cs @@ -71,7 +71,7 @@ public partial class Utility .Confirm(GetText(strs.quotes_page(page + 1)), string.Join("\n", quotes.Select(q - => $"`#{q.Id}` {Format.Bold(q.Keyword.SanitizeAllMentions()),-20} by {q.AuthorName.SanitizeAllMentions()}"))) + => $"`{new kwum(q.Id)}` {Format.Bold(q.Keyword.SanitizeAllMentions()),-20} by {q.AuthorName.SanitizeAllMentions()}"))) .SendAsync(); } else @@ -107,19 +107,19 @@ public partial class Utility text = await repSvc.ReplaceAsync(text, repCtx); await Response() - .Text($"`#{quote.Id}` 📣 " + text) + .Text($"`{new kwum(quote.Id)}` 📣 " + text) .Sanitize() .SendAsync(); } [Cmd] [RequireContext(ContextType.Guild)] - public async Task QuoteShow(int id) + public async Task QuoteShow(kwum quoteId) { Quote? quote; await using (var uow = _db.GetDbContext()) { - quote = uow.Set().GetById(id); + quote = uow.Set().GetById(quoteId); if (quote?.GuildId != ctx.Guild.Id) quote = null; } @@ -137,7 +137,7 @@ public partial class Utility { var eb = _sender.CreateEmbed() .WithOkColor() - .WithTitle($"{GetText(strs.quote_id($"#{data.Id}"))} | {GetText(strs.response)}:") + .WithTitle($"{GetText(strs.quote_id($"`{new kwum(data.Id)}"))}`") .WithDescription(Format.Sanitize(data.Text).Replace("](", "]\\(").TrimTo(4096)) .AddField(GetText(strs.trigger), data.Keyword) .WithFooter( @@ -174,7 +174,7 @@ public partial class Utility return; await Response() - .Confirm($"`#{quote.Id}` 💬 ", + .Confirm($"`{new kwum(quote.Id)}` 💬 ", quote.Keyword.ToLowerInvariant() + ": " + quote.Text.SanitizeAllMentions()) @@ -195,9 +195,9 @@ public partial class Utility [Cmd] [RequireContext(ContextType.Guild)] - public async Task QuoteId(int id) + public async Task QuoteId(kwum quoteId) { - if (id < 0) + if (quoteId < 0) return; Quote quote; @@ -206,7 +206,7 @@ public partial class Utility await using (var uow = _db.GetDbContext()) { - quote = uow.Set().GetById(id); + quote = uow.Set().GetById(quoteId); } if (quote is null || quote.GuildId != ctx.Guild.Id) @@ -215,7 +215,7 @@ public partial class Utility return; } - var infoText = $"`#{quote.Id} added by {quote.AuthorName.SanitizeAllMentions()}` 🗯️ " + var infoText = $"*`{new kwum(quote.Id)}` added by {quote.AuthorName.SanitizeAllMentions()}* 🗯️ " + quote.Keyword.ToLowerInvariant().SanitizeAllMentions() + ":\n"; @@ -252,12 +252,12 @@ public partial class Utility await uow.SaveChangesAsync(); } - await Response().Confirm(strs.quote_added_new(Format.Code(q.Id.ToString()))).SendAsync(); + await Response().Confirm(strs.quote_added_new(Format.Code(new kwum(q.Id).ToString()))).SendAsync(); } [Cmd] [RequireContext(ContextType.Guild)] - public async Task QuoteDelete(int id) + public async Task QuoteDelete(kwum quoteId) { var hasManageMessages = ((IGuildUser)ctx.Message.Author).GuildPermissions.ManageMessages; @@ -265,7 +265,7 @@ public partial class Utility string response; await using (var uow = _db.GetDbContext()) { - var q = uow.Set().GetById(id); + var q = uow.Set().GetById(quoteId); if (q?.GuildId != ctx.Guild.Id || (!hasManageMessages && q.AuthorId != ctx.Message.Author.Id)) response = GetText(strs.quotes_remove_none); @@ -274,7 +274,7 @@ public partial class Utility uow.Set().Remove(q); await uow.SaveChangesAsync(); success = true; - response = GetText(strs.quote_deleted(id)); + response = GetText(strs.quote_deleted(new kwum(quoteId))); } }