Skip to content

Commit d6b8ccd

Browse files
committed
Improve error messages in artifact-levels
1 parent 366eaeb commit d6b8ccd

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/commands/artifacts/artifact-levels.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Note: this command supports fuzzy search.`,
3333
}, {
3434
name: "stars",
3535
description: "Rarity of the artifact (default: 5)",
36-
type: "NUMBER"
36+
type: "INTEGER"
3737
}]
3838
})
3939
}
@@ -42,25 +42,26 @@ Note: this command supports fuzzy search.`,
4242
const { options } = source
4343

4444
const mainStat = options.getString("mainstat", true)
45-
const stars = options.getNumber("stars") ?? 5
45+
const stars = options.getInteger("stars") ?? 5
4646

4747
return this.run(source, mainStat, stars)
4848
}
4949

5050
async runMessage(source: Message, args: string[]): Promise<SendMessage | undefined> {
51+
if (args.length == 0)
52+
return await this.sendHelp(source)
53+
5154
const { data } = client
5255
const keys = Object.keys(data.artifactMainLevels)
53-
54-
if (args.length == 0) {
55-
if (!keys) return sendMessage(source, "No artifact level data loaded", undefined, true)
56-
57-
return await this.sendHelp(source)
58-
}
56+
if (!keys) return sendMessage(source, "No artifact level data loaded", undefined, true)
5957

6058
let stars = 5
6159
if (!isNaN(parseInt(args[args.length - 1])))
6260
stars = parseInt(args.pop() ?? "5")
6361

62+
if (args.length == 0)
63+
return await this.sendHelp(source)
64+
6465
const mainStat = findFuzzy(keys, args.join(" "))
6566
if (mainStat == undefined)
6667
return sendMessage(source, "Unable to find main stat", undefined, true)
@@ -72,6 +73,9 @@ Note: this command supports fuzzy search.`,
7273
const { data } = client
7374

7475
const levelData = data.artifactMainLevels[mainStat][stars]
76+
if (levelData == undefined)
77+
return sendMessage(source, `Unable to find \`${stars}\`★ stats for \`${mainStat}\``, undefined, true)
78+
7579
const entries = Object.entries(levelData)
7680

7781
const table = []

0 commit comments

Comments
 (0)