Bot will now 'try' to set status to invisible before going offline when '.die' command is used, but it doesn't seem to have (much/any) effect. .qsearch is more powerful

This commit is contained in:
Kwoth
2022-07-03 22:26:41 +02:00
parent 643987c41f
commit 4d175477f5
5 changed files with 35 additions and 20 deletions

View File

@@ -335,6 +335,7 @@ public partial class Administration
{
try
{
await _client.SetStatusAsync(UserStatus.DoNotDisturb);
await ReplyConfirmLocalizedAsync(strs.shutting_down);
}
catch

View File

@@ -1,4 +1,4 @@
#nullable disable
#nullable disable warnings
using NadekoBot.Common.Yml;
using NadekoBot.Db;
using NadekoBot.Services.Database.Models;
@@ -134,30 +134,40 @@ public partial class Utility
.WithFooter(
GetText(strs.created_by($"{data.AuthorName} ({data.AuthorId})"))));
[Cmd]
[RequireContext(ContextType.Guild)]
public async partial Task QuoteSearch(string keyword, [Leftover] string text)
private async Task QuoteSearchinternalAsync(string? keyword, string textOrAuthor)
{
if (string.IsNullOrWhiteSpace(keyword) || string.IsNullOrWhiteSpace(text))
if (string.IsNullOrWhiteSpace(textOrAuthor))
return;
keyword = keyword.ToUpperInvariant();
keyword = keyword?.ToUpperInvariant();
Quote keywordquote;
Quote quote;
await using (var uow = _db.GetDbContext())
{
keywordquote = await uow.Quotes.SearchQuoteKeywordTextAsync(ctx.Guild.Id, keyword, text);
quote = await uow.Quotes.SearchQuoteKeywordTextAsync(ctx.Guild.Id, keyword, textOrAuthor);
}
if (keywordquote is null)
if (quote is null)
return;
await ctx.Channel.SendMessageAsync($"`#{keywordquote.Id}` 💬 "
+ keyword.ToLowerInvariant()
await ctx.Channel.SendMessageAsync($"`#{quote.Id}` 💬 "
+ quote.Keyword.ToLowerInvariant()
+ ": "
+ keywordquote.Text.SanitizeAllMentions());
+ quote.Text.SanitizeAllMentions());
}
[Cmd]
[RequireContext(ContextType.Guild)]
[Priority(0)]
public partial Task QuoteSearch(string textOrAuthor)
=> QuoteSearchinternalAsync(null, textOrAuthor);
[Cmd]
[RequireContext(ContextType.Guild)]
[Priority(1)]
public partial Task QuoteSearch(string keyword, [Leftover] string textOrAuthor)
=> QuoteSearchinternalAsync(keyword, textOrAuthor);
[Cmd]
[RequireContext(ContextType.Guild)]
public async partial Task QuoteId(int id)