workaround new bug in discord client

how do you fail to find user in cache after you just explicitly loaded it from the server
This commit is contained in:
13xforever
2021-03-03 20:26:49 +05:00
parent 3223b94e43
commit c98e207bc8
3 changed files with 11 additions and 3 deletions

View File

@@ -107,7 +107,7 @@ namespace CompatBot.Commands
public async Task Import(CommandContext ctx, string? url = null)
{
var msg = await ctx.RespondAsync("Please wait...").ConfigureAwait(false);
if (!ImportCheck.Wait(0))
if (!await ImportCheck.WaitAsync(0).ConfigureAwait(false))
{
await ctx.ReactWithAsync(Config.Reactions.Failure).ConfigureAwait(false);
await msg.UpdateOrCreateMessageAsync(ctx.Channel, "There is another import in progress already").ConfigureAwait(false);

View File

@@ -97,8 +97,15 @@ namespace CompatBot.Commands
var headerLength = result.Length;
var members = GetMembers(ctx.Client);
foreach (var member in members)
if (UsernameZalgoMonitor.NeedsRename(member.DisplayName))
result.AppendLine($"{member.Mention} please change your nickname according to Rule #7");
try
{
if (UsernameZalgoMonitor.NeedsRename(member.DisplayName))
result.AppendLine($"{member.Mention} please change your nickname according to Rule #7");
}
catch (Exception e)
{
Config.Log.Warn(e, $"Failed to audit username for {member.Id}");
}
if (result.Length == headerLength)
result.AppendLine("No naughty users 🎉");
await ctx.SendAutosplitMessageAsync(result, blockStart: "", blockEnd: "").ConfigureAwait(false);

View File

@@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<NoWarn>1701;1702;RS2008</NoWarn>
</PropertyGroup>
<ItemGroup>