Using args functionality on another message

Hello, I want to use the Args.pickResult() function on another message. Is there any way I can do this? For example, making an args object for that message?
1 Reply
Favna
Favna2y ago
rather than using pickResult and the like you can use the resolvers which args use internally.
import { Resolvers } from '@sapphire/framework';

// etc...

const user = Resolvers.resolveUser(message.content);
import { Resolvers } from '@sapphire/framework';

// etc...

const user = Resolvers.resolveUser(message.content);
user now has the type
Result<User, Identifiers.ArgumentUserError>
Result<User, Identifiers.ArgumentUserError>
so you can then call the same methods as you would after a pickResult
if (user.isOk()) {
// Do something with user
}
if (user.isOk()) {
// Do something with user
}
All the built in args are exposed as resolvers:
resolveBoolean
resolveChannel
resolveDMChannel
resolveDate
resolveEmoji
resolveEnum
resolveFloat
resolveGuild
resolveGuildCategoryChannel
resolveGuildChannel
resolveGuildNewsChannel
resolveGuildNewsThreadChannel
resolveGuildPrivateThreadChannel
resolveGuildPublicThreadChannel
resolveGuildStageVoiceChannel
resolveGuildTextChannel
resolveGuildThreadChannel
resolveGuildVoiceChannel
resolveHyperlink
resolveInteger
resolveMember
resolveMessage
resolveNumber
resolvePartialDMChannel
resolveRole
resolveString
resolveUser
resolveBoolean
resolveChannel
resolveDMChannel
resolveDate
resolveEmoji
resolveEnum
resolveFloat
resolveGuild
resolveGuildCategoryChannel
resolveGuildChannel
resolveGuildNewsChannel
resolveGuildNewsThreadChannel
resolveGuildPrivateThreadChannel
resolveGuildPublicThreadChannel
resolveGuildStageVoiceChannel
resolveGuildTextChannel
resolveGuildThreadChannel
resolveGuildVoiceChannel
resolveHyperlink
resolveInteger
resolveMember
resolveMessage
resolveNumber
resolvePartialDMChannel
resolveRole
resolveString
resolveUser
Want results from more Discord servers?
Add your server