Fix system lookup errors where user ID doesn't exist
This commit is contained in:
parent
720755844f
commit
cad5b71f14
@ -2,6 +2,7 @@ using System.Linq;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using DSharpPlus;
|
using DSharpPlus;
|
||||||
|
using DSharpPlus.Exceptions;
|
||||||
|
|
||||||
using PluralKit.Core;
|
using PluralKit.Core;
|
||||||
|
|
||||||
@ -346,13 +347,17 @@ namespace PluralKit.Bot
|
|||||||
{
|
{
|
||||||
// Try to resolve the user ID to find the associated account,
|
// Try to resolve the user ID to find the associated account,
|
||||||
// so we can print their username.
|
// so we can print their username.
|
||||||
|
try
|
||||||
|
{
|
||||||
var user = await ctx.Rest.GetUserAsync(id);
|
var user = await ctx.Rest.GetUserAsync(id);
|
||||||
|
|
||||||
// Print descriptive errors based on whether we found the user or not.
|
|
||||||
if (user == null)
|
|
||||||
return $"Account with ID `{id}` not found.";
|
|
||||||
return $"Account **{user.Username}#{user.Discriminator}** does not have a system registered.";
|
return $"Account **{user.Username}#{user.Discriminator}** does not have a system registered.";
|
||||||
}
|
}
|
||||||
|
catch (NotFoundException)
|
||||||
|
{
|
||||||
|
// User not found, just return ID
|
||||||
|
return $"Account with ID `{id}` not found.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $"System with ID `{input}` not found.";
|
return $"System with ID `{input}` not found.";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user