Skip to content

Commit bd57fbd

Browse files
authored
Merge pull request #9 from pk9r/dev
Enhance TcgSlashCommand to handle missing Hoyolab account and provide…
2 parents 8aa14a4 + 007558d commit bd57fbd

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

src/GitcgNetCord.MainApp/Commands/Slash/TcgSlashCommand.cs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,33 @@ await context.Interaction.SendResponseAsync(
4343
var hoyolabAccount = await activeHoyolabAccountService
4444
.GetActiveHoyolabAccountAsync(context.User.Id);
4545

46+
var commands = await context.Client.Rest
47+
.GetGlobalApplicationCommandsAsync(context.Client.Id);
48+
49+
var accountCommand = commands
50+
.First(x => x.Name == "hoyolab-accounts");
51+
52+
if (hoyolabAccount == null && string.IsNullOrWhiteSpace(uid))
53+
{
54+
55+
await context.Interaction.ModifyResponseAsync(message =>
56+
{
57+
message.AddEmbeds(new EmbedProperties()
58+
.WithTitle("Error")
59+
.WithDescription(
60+
$"""
61+
You must have a Hoyolab account linked to your Discord account, or provide a UID.
62+
Please use the {accountCommand} command to link your Hoyolab account.
63+
Alternatively, you can provide a UID directly.
64+
"""
65+
)
66+
.WithColor(new NetCord.Color(Color.Red.ToArgb()))
67+
);
68+
});
69+
70+
return;
71+
}
72+
4673
HoyolabAuthorize? authorize = null;
4774
if (hoyolabAccount != null)
4875
{
@@ -76,10 +103,15 @@ await context.Interaction.ModifyResponseAsync(message =>
76103
{
77104
message.AddEmbeds(new EmbedProperties()
78105
.WithTitle("Error")
79-
.WithDescription(e.Message)
106+
.WithDescription(
107+
$"""
108+
{e.Message}
109+
If the UID is your own, use the command {accountCommand} to set up your Hoyolab account.
110+
""")
80111
.WithColor(redColor)
81112
);
82113
});
114+
83115
return;
84116
}
85117

0 commit comments

Comments
 (0)