Downgrade to v13

[vi] cảm giác đau khổ
This commit is contained in:
March 7th
2022-03-24 17:55:32 +07:00
parent 9596b1a210
commit 7dfdef46a5
218 changed files with 8584 additions and 9108 deletions

View File

@@ -1,6 +1,5 @@
'use strict';
const { ApplicationCommandOptionType } = require('discord-api-types/v9');
const { TypeError } = require('../errors');
/**
@@ -39,12 +38,12 @@ class CommandInteractionOptionResolver {
this._hoistedOptions = options;
// Hoist subcommand group if present
if (this._hoistedOptions[0]?.type === ApplicationCommandOptionType.SubcommandGroup) {
if (this._hoistedOptions[0]?.type === 'SUB_COMMAND_GROUP') {
this._group = this._hoistedOptions[0].name;
this._hoistedOptions = this._hoistedOptions[0].options ?? [];
}
// Hoist subcommand if present
if (this._hoistedOptions[0]?.type === ApplicationCommandOptionType.Subcommand) {
if (this._hoistedOptions[0]?.type === 'SUB_COMMAND') {
this._subcommand = this._hoistedOptions[0].name;
this._hoistedOptions = this._hoistedOptions[0].options ?? [];
}
@@ -117,10 +116,10 @@ class CommandInteractionOptionResolver {
/**
* Gets the selected subcommand group.
* @param {boolean} [required=false] Whether to throw an error if there is no subcommand group.
* @param {boolean} [required=true] Whether to throw an error if there is no subcommand group.
* @returns {?string} The name of the selected subcommand group, or null if not set and not required.
*/
getSubcommandGroup(required = false) {
getSubcommandGroup(required = true) {
if (required && !this._group) {
throw new TypeError('COMMAND_INTERACTION_OPTION_NO_SUB_COMMAND_GROUP');
}
@@ -134,7 +133,7 @@ class CommandInteractionOptionResolver {
* @returns {?boolean} The value of the option, or null if not set and not required.
*/
getBoolean(name, required = false) {
const option = this._getTypedOption(name, ApplicationCommandOptionType.Boolean, ['value'], required);
const option = this._getTypedOption(name, 'BOOLEAN', ['value'], required);
return option?.value ?? null;
}
@@ -146,7 +145,7 @@ class CommandInteractionOptionResolver {
* The value of the option, or null if not set and not required.
*/
getChannel(name, required = false) {
const option = this._getTypedOption(name, ApplicationCommandOptionType.Channel, ['channel'], required);
const option = this._getTypedOption(name, 'CHANNEL', ['channel'], required);
return option?.channel ?? null;
}
@@ -157,7 +156,7 @@ class CommandInteractionOptionResolver {
* @returns {?string} The value of the option, or null if not set and not required.
*/
getString(name, required = false) {
const option = this._getTypedOption(name, ApplicationCommandOptionType.String, ['value'], required);
const option = this._getTypedOption(name, 'STRING', ['value'], required);
return option?.value ?? null;
}
@@ -168,7 +167,7 @@ class CommandInteractionOptionResolver {
* @returns {?number} The value of the option, or null if not set and not required.
*/
getInteger(name, required = false) {
const option = this._getTypedOption(name, ApplicationCommandOptionType.Integer, ['value'], required);
const option = this._getTypedOption(name, 'INTEGER', ['value'], required);
return option?.value ?? null;
}
@@ -179,7 +178,7 @@ class CommandInteractionOptionResolver {
* @returns {?number} The value of the option, or null if not set and not required.
*/
getNumber(name, required = false) {
const option = this._getTypedOption(name, ApplicationCommandOptionType.Number, ['value'], required);
const option = this._getTypedOption(name, 'NUMBER', ['value'], required);
return option?.value ?? null;
}
@@ -190,18 +189,19 @@ class CommandInteractionOptionResolver {
* @returns {?User} The value of the option, or null if not set and not required.
*/
getUser(name, required = false) {
const option = this._getTypedOption(name, ApplicationCommandOptionType.User, ['user'], required);
const option = this._getTypedOption(name, 'USER', ['user'], required);
return option?.user ?? null;
}
/**
* 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|APIGuildMember)}
* The value of the option, or null if the user is not present in the guild or the option is not set.
* The value of the option, or null if not set and not required.
*/
getMember(name) {
const option = this._getTypedOption(name, ApplicationCommandOptionType.User, ['member'], false);
getMember(name, required = false) {
const option = this._getTypedOption(name, 'USER', ['member'], required);
return option?.member ?? null;
}
@@ -212,21 +212,10 @@ class CommandInteractionOptionResolver {
* @returns {?(Role|APIRole)} The value of the option, or null if not set and not required.
*/
getRole(name, required = false) {
const option = this._getTypedOption(name, ApplicationCommandOptionType.Role, ['role'], required);
const option = this._getTypedOption(name, 'ROLE', ['role'], required);
return option?.role ?? null;
}
/**
* Gets an attachment 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 {?MessageAttachment} The value of the option, or null if not set and not required.
*/
getAttachment(name, required = false) {
const option = this._getTypedOption(name, ApplicationCommandOptionType.Attachment, ['attachment'], required);
return option?.attachment ?? null;
}
/**
* Gets a mentionable option.
* @param {string} name The name of the option.
@@ -235,12 +224,7 @@ class CommandInteractionOptionResolver {
* The value of the option, or null if not set and not required.
*/
getMentionable(name, required = false) {
const option = this._getTypedOption(
name,
ApplicationCommandOptionType.Mentionable,
['user', 'member', 'role'],
required,
);
const option = this._getTypedOption(name, 'MENTIONABLE', ['user', 'member', 'role'], required);
return option?.member ?? option?.user ?? option?.role ?? null;
}