-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(emoji-argument): Apply review changes
- Loading branch information
1 parent
9ad6feb
commit c9d9892
Showing
3 changed files
with
12 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,21 @@ | ||
import type { PieceContext } from '@sapphire/pieces'; | ||
import type { GuildEmoji } from 'discord.js'; | ||
import { Identifiers } from '../lib/errors/Identifiers'; | ||
import { GuildEmojiStructure, resolveEmoji } from '../lib/resolvers/emoji'; | ||
import { EmojiObject, resolveEmoji } from '../lib/resolvers/emoji'; | ||
import { Argument, ArgumentResult } from '../lib/structures/Argument'; | ||
|
||
export default class extends Argument<GuildEmoji | string> { | ||
export default class extends Argument<EmojiObject | string> { | ||
public constructor(context: PieceContext) { | ||
super(context, { name: 'emoji' }); | ||
} | ||
|
||
public run(parameter: string): ArgumentResult<GuildEmoji | string> { | ||
public run(parameter: string): ArgumentResult<EmojiObject | string> { | ||
const resolved = resolveEmoji(parameter); | ||
return resolved.success | ||
? this.ok(this.parseSuccess(resolved.value)) | ||
? this.ok(resolved.value) | ||
: this.error({ | ||
parameter, | ||
identifier: Identifiers.ArgumentEmojiError, | ||
message: 'The argument did not resolve to an emoji.' | ||
}); | ||
} | ||
|
||
public parseSuccess(resolvedValue: string | GuildEmojiStructure): GuildEmoji | string { | ||
if (resolvedValue instanceof Object) { | ||
const resolvedGuildEmoji = resolvedValue as GuildEmojiStructure; | ||
return this.container.client.emojis.resolve(resolvedGuildEmoji.id)!; | ||
} | ||
|
||
return resolvedValue; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters