feat: right-clickybois (context menu support for ApplicationCommand and CommandInteraction) (#6176)

Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com>
This commit is contained in:
monbrey
2021-08-11 08:56:12 +10:00
committed by GitHub
parent 779e14ef61
commit 0266f28096
12 changed files with 328 additions and 180 deletions

View File

@@ -134,7 +134,7 @@ class CommandInteractionOptionResolver {
* Gets a channel option.
* @param {string} name The name of the option.
* @param {boolean} [required=false] Whether to throw an error if the option is not found.
* @returns {?(GuildChannel|APIInteractionDataResolvedOption)}
* @returns {?(GuildChannel|APIGuildChannel)}
* The value of the option, or null if not set and not required.
*/
getChannel(name, required = false) {
@@ -190,7 +190,7 @@ class CommandInteractionOptionResolver {
* Gets a member option.
* @param {string} name The name of the option.
* @param {boolean} [required=false] Whether to throw an error if the option is not found.
* @returns {?(GuildMember|APIInteractionDataResolvedOption)}
* @returns {?(GuildMember|APIGuildMember)}
* The value of the option, or null if not set and not required.
*/
getMember(name, required = false) {
@@ -213,13 +213,25 @@ class CommandInteractionOptionResolver {
* Gets a mentionable option.
* @param {string} name The name of the option.
* @param {boolean} [required=false] Whether to throw an error if the option is not found.
* @returns {?(User|GuildMember|APIInteractionDataResolvedOption|Role|APIRole)}
* @returns {?(User|GuildMember|APIGuildMember|Role|APIRole)}
* The value of the option, or null if not set and not required.
*/
getMentionable(name, required = false) {
const option = this._getTypedOption(name, 'MENTIONABLE', ['user', 'member', 'role'], required);
return option?.member ?? option?.user ?? option?.role ?? null;
}
/**
* Gets a message option.
* @param {string} name The name of the option.
* @param {boolean} [required=false] Whether to throw an error if the option is not found.
* @returns {?(Message|APIMessage)}
* The value of the option, or null if not set and not required.
*/
getMessage(name, required = false) {
const option = this._getTypedOption(name, '_MESSAGE', ['message'], required);
return option?.message ?? null;
}
}
module.exports = CommandInteractionOptionResolver;