mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-13 01:00:12 +00:00
Create GetXXX utils wrapping try blocks
This commit is contained in:
parent
7fef8c1dde
commit
c87e67245d
8 changed files with 95 additions and 49 deletions
|
|
@ -355,16 +355,11 @@ namespace PluralKit.Bot
|
|||
{
|
||||
// Try to resolve the user ID to find the associated account,
|
||||
// so we can print their username.
|
||||
try
|
||||
{
|
||||
var user = await ctx.Rest.GetUserAsync(id);
|
||||
var user = await ctx.Shard.GetUser(id);
|
||||
if (user != null)
|
||||
return $"Account **{user.Username}#{user.Discriminator}** does not have a system registered.";
|
||||
}
|
||||
catch (NotFoundException)
|
||||
{
|
||||
// User not found, just return ID
|
||||
else
|
||||
return $"Account with ID `{id}` not found.";
|
||||
}
|
||||
}
|
||||
|
||||
return $"System with ID `{input}` not found.";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue