diff --git a/.eslintrc.ts.yml b/.eslintrc.ts.yml deleted file mode 100644 index 42494190..00000000 --- a/.eslintrc.ts.yml +++ /dev/null @@ -1,67 +0,0 @@ ---- -extends: -- "./.eslintrc.yml" -- plugin:@typescript-eslint/eslint-recommended -- plugin:@typescript-eslint/recommended -rules: - "@typescript-eslint/indent": - - 2 - - 2 - - SwitchCase: 1 - ignoreComments: false - "@typescript-eslint/member-delimiter-style": 2 - "@typescript-eslint/no-explicit-any": 0 - "@typescript-eslint/consistent-type-definitions": 2 - "@typescript-eslint/semi": - - 2 - - always - "@typescript-eslint/ban-ts-comment": - - 2 - - ts-expect-error: allow-with-description - ts-ignore: allow-with-description - indent: 0 - keyword-spacing: - - 2 - - after: true - object-curly-spacing: - - 2 - - always - semi: 0 - sort-class-members/sort-class-members: - - 2 - - order: - - "[screaming-snake-case-static-properties]" - - "[alphabetical-static-properties]" - - "[alphabetical-properties]" - - constructor - - "[alphabetical-static-methods]" - - "[alphabetical-methods]" - - 'on' - - "[everything-else]" - - "[custom-inspect-method]" - - toString - - toJSON - groups: - screaming-snake-case-static-properties: - - name: "/^[A-Z_0-9]+$/" - type: property - static: true - alphabetical-static-properties: - - type: property - sort: alphabetical - static: true - alphabetical-static-methods: - - type: method - sort: alphabetical - static: true - alphabetical-methods: - - type: method - sort: alphabetical - static: false - alphabetical-properties: - - type: property - sort: alphabetical - static: false - custom-inspect-method: - - name: "[util.inspect.custom]" - type: method diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index d6960da3..00000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,95 +0,0 @@ ---- -env: - es2022: true - node: true -plugins: - - "sort-class-members" -extends: "eslint:recommended" -globals: - window: true -rules: - array-bracket-spacing: - - 2 - - never - arrow-parens: 2 - brace-style: - - 2 - - 1tbs - - allowSingleLine: false - comma-dangle: - - 2 - - never - curly: 2 - eol-last: - - 2 - - always - indent: - - 2 - - 4 - - SwitchCase: 1 - ignoreComments: false - keyword-spacing: - - 2 - - after: true - overrides: - catch: - after: false - for: - after: false - if: - after: false - switch: - after: false - while: - after: false - no-prototype-builtins: 0 - no-trailing-spaces: 2 - no-var: 2 - object-curly-spacing: - - 2 - - never - object-shorthand: - - 2 - - consistent-as-needed - prefer-const: 2 - quotes: - - 2 - - double - require-atomic-updates: 1 - semi: - - 2 - - always - sort-class-members/sort-class-members: - - 2 - - order: - - "[alphabetical-properties]" - - constructor - - update - - "[alphabetical-getters]" - - "[alphabetical-methods]" - - "[alphabetical-conventional-private-methods]" - - "[everything-else]" - - "[alphabetical-private-methods]" - - "[custom-inspect-method]" - - toString - - toJSON - groups: - alphabetical-getters: - - kind: get - sort: alphabetical - alphabetical-methods: - - type: method - sort: alphabetical - alphabetical-properties: - - type: property - sort: alphabetical - alphabetical-conventional-private-methods: - - name: "/_.+/" - type: method - sort: alphabetical - alphabetical-private-methods: - - type: method - sort: alphabetical - custom-inspect-method: - - name: "[util.inspect.custom]" - type: method diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e54c8894..6146939b 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -3,18 +3,9 @@ on: [ pull_request ] jobs: lint: - name: Lint ${{ matrix.lang.name }} files + name: Lint all files runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - lang: - - lang: js - name: JavaScript - - lang: ts - name: TypeScript - steps: - name: Setup Node.js uses: actions/setup-node@v4 @@ -24,6 +15,5 @@ jobs: uses: actions/checkout@v4 - name: Install dependencies run: npm i --omit=optional - - name: Lint ${{ matrix.lang.name }} files - run: "npm run lint:${{ matrix.lang.lang }}" - + - name: Lint all files + run: "npm run lint" diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..7df0858b --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,256 @@ +import js from "@eslint/js"; +import stylistic from "@stylistic/eslint-plugin"; +import ts from "typescript-eslint"; +import globals from "globals"; +import sortClassMembers from "eslint-plugin-sort-class-members"; +import jsdoc from "eslint-plugin-jsdoc"; + +const cjsFiles = [ + "lib/**/*.js", + "examples/**/*.js", + "*.js" +]; + +const jsFiles = [ + ...cjsFiles, + "lib/**/*.mjs", + "examples/**/*.mjs", + "*.mjs" +]; + +const tsFiles = [ + "lib/**/*.ts", + "examples/**/*.ts", + "*.ts" +]; + +const classSortCommon = { + groups: { + "alphabetical-getters": [ + { + kind: "get", + sort: "alphabetical", + static: false + } + ], + "alphabetical-methods": [ + { + type: "method", + sort: "alphabetical", + static: false + } + ], + "alphabetical-properties": [ + { + type: "property", + sort: "alphabetical", + static: false + } + ], + "alphabetical-private-properties": [ + { + type: "property", + sort: "alphabetical", + private: true + } + ], + "alphabetical-conventional-private-methods": [ + { + name: "/_.+/", + type: "method", + sort: "alphabetical" + } + ], + "alphabetical-private-methods": [ + { + type: "method", + sort: "alphabetical", + private: true + } + ], + "custom-inspect-method": [ + { + name: "[util.inspect.custom]", + type: "method" + } + ], + "screaming-snake-case-static-properties": [ + { + name: "/^[A-Z_0-9]+$/", + type: "property", + static: true + } + ], + "alphabetical-static-properties": [ + { + type: "property", + sort: "alphabetical", + static: true + } + ], + "alphabetical-static-methods": [ + { + type: "method", + sort: "alphabetical", + static: true + } + ] + } +}; + +export default ts.config( + { + files: jsFiles, + extends: [ + js.configs.recommended + ], + plugins: { + "sort-class-members": sortClassMembers + }, + languageOptions: { + globals: { + window: true, + ...globals.node + } + }, + rules: { + "curly": "error", + "no-prototype-builtins": "off", + "no-trailing-spaces": "error", + "no-var": "error", + "object-shorthand": [ + "error", + "consistent-as-needed" + ], + "prefer-const": "error", + "require-atomic-updates": "warn", + "sort-class-members/sort-class-members": [ + "error", + { + ...classSortCommon, + order: [ + "[alphabetical-properties]", + "[alphabetical-private-properties]", + "constructor", + "update", + "[alphabetical-getters]", + "[alphabetical-methods]", + "[alphabetical-conventional-private-methods]", + "[alphabetical-private-methods]", + "[everything-else]", + "[custom-inspect-method]", + "toString", + "toJSON" + ] + } + ] + } + }, + { + files: cjsFiles, + languageOptions: { + sourceType: "commonjs" + }, + plugins: { + jsdoc + }, + settings: { + jsdoc: { + preferredTypes: { + bigint: "BigInt", + boolean: "Boolean", + number: "Number", + object: "Object", + string: "String" + }, + tagNamePreference: { + property: "prop", + augments: "extends" + } + } + }, + rules: { + "jsdoc/check-types": "error", + "jsdoc/check-tag-names": "error", + "jsdoc/check-alignment": "error" + } + }, + { + files: [ + "**/*.ts" + ], + extends: [ + ...ts.configs.recommended + ], + rules: { + "@typescript-eslint/consistent-type-definitions": "error" + } + }, + { + files: [ + ...jsFiles, + ...tsFiles + ], + extends: [ + stylistic.configs.customize({ + arrowParens: true, + braceStyle: "1tbs", + indent: 4, + quotes: "double", + semi: true, + commaDangle: "never" + }) + ], + rules: { + "@stylistic/keyword-spacing": [ + "error", + { + after: true, + overrides: { + catch: {after: false}, + for: {after: false}, + if: {after: false}, + switch: {after: false}, + while: {after: false} + } + } + ], + "@stylistic/object-curly-spacing": [ + "error", + "never" + ], + "@stylistic/space-before-function-paren": "off" + } + }, + { + files: ["index.d.ts"], + plugins: { + "sort-class-members": sortClassMembers + }, + rules: { + "@stylistic/indent": ["error", 2], + "@stylistic/object-curly-spacing": ["error", "always"], + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/ban-ts-comment": ["error", { + "ts-expect-error": "allow-with-description", + "ts-ignore": "allow-with-description" + }], + "sort-class-members/sort-class-members": ["error", { + ...classSortCommon, + order: [ + "[screaming-snake-case-static-properties]", + "[alphabetical-static-properties]", + "[alphabetical-properties]", + "constructor", + "[alphabetical-static-methods]", + "[alphabetical-methods]", + "on", + "[everything-else]", + "[custom-inspect-method]", + "toString", + "toJSON" + ] + }] + } + } +); diff --git a/esm.mjs b/esm.mjs index 56205a64..031a1a57 100644 --- a/esm.mjs +++ b/esm.mjs @@ -1,60 +1,59 @@ import Dysnomia from "./index.js"; - export const { - ApplicationCommand, - Attachment, - AutocompleteInteraction, - AutoModerationRule, - Base, - Bucket, - CategoryChannel, - Channel, - Client, - Collection, - CommandInteraction, - ComponentInteraction, - Constants, - DiscordHTTPError, - DiscordRESTError, - ExtendedUser, - ForumChannel, - Guild, - GuildChannel, - GuildIntegration, - GuildPreview, - GuildScheduledEvent, - GuildTemplate, - Interaction, - Invite, - MediaChannel, - Member, - Message, - ModalSubmitInteraction, - NewsChannel, - NewsThreadChannel, - Permission, - PermissionOverwrite, - PingInteraction, - PrivateChannel, - PrivateThreadChannel, - PublicThreadChannel, - RequestHandler, - Role, - SequentialBucket, - Shard, - SharedStream, - StageChannel, - StageInstance, - TextChannel, - TextVoiceChannel, - ThreadChannel, - ThreadMember, - UnavailableGuild, - User, - VERSION, - VoiceChannel, - VoiceConnection, - VoiceConnectionManager, - VoiceState + ApplicationCommand, + Attachment, + AutocompleteInteraction, + AutoModerationRule, + Base, + Bucket, + CategoryChannel, + Channel, + Client, + Collection, + CommandInteraction, + ComponentInteraction, + Constants, + DiscordHTTPError, + DiscordRESTError, + ExtendedUser, + ForumChannel, + Guild, + GuildChannel, + GuildIntegration, + GuildPreview, + GuildScheduledEvent, + GuildTemplate, + Interaction, + Invite, + MediaChannel, + Member, + Message, + ModalSubmitInteraction, + NewsChannel, + NewsThreadChannel, + Permission, + PermissionOverwrite, + PingInteraction, + PrivateChannel, + PrivateThreadChannel, + PublicThreadChannel, + RequestHandler, + Role, + SequentialBucket, + Shard, + SharedStream, + StageChannel, + StageInstance, + TextChannel, + TextVoiceChannel, + ThreadChannel, + ThreadMember, + UnavailableGuild, + User, + VERSION, + VoiceChannel, + VoiceConnection, + VoiceConnectionManager, + VoiceState } = Dysnomia; diff --git a/examples/applicationCommands.js b/examples/applicationCommands.js index d4d6119f..b13141e3 100644 --- a/examples/applicationCommands.js +++ b/examples/applicationCommands.js @@ -5,7 +5,7 @@ const Constants = Dysnomia.Constants; // Replace TOKEN with your bot account's token const bot = new Dysnomia.Client("BOT TOKEN", { gateway: { - intents: [] //No intents are needed for interactions, but you still need to specify either an empty array or 0 + intents: [] // No intents are needed for interactions, but you still need to specify either an empty array or 0 } }); @@ -18,60 +18,60 @@ bot.on("ready", async () => { // When the bot is ready bot.createCommand({ name: "test_chat_input", description: "Test command to show how to make commands", - options: [ //An array of Chat Input options https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure + options: [ // An array of Chat Input options https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure { - "name": "animal", //The name of the option - "description": "The type of animal", - "type": Constants.ApplicationCommandOptionTypes.STRING, //This is the type of string, see the types here https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type - "required": true, - "choices": [ //The possible choices for the options + name: "animal", // The name of the option + description: "The type of animal", + type: Constants.ApplicationCommandOptionTypes.STRING, // This is the type of string, see the types here https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type + required: true, + choices: [ // The possible choices for the options { - "name": "Dog", - "value": "animal_dog" + name: "Dog", + value: "animal_dog" }, { - "name": "Cat", - "value": "animal_cat" + name: "Cat", + value: "animal_cat" }, { - "name": "Penguin", - "value": "animal_penguin" + name: "Penguin", + value: "animal_penguin" } ] }, { - "name": "only_smol", - "description": "Whether to show only baby animals", - "type": Constants.ApplicationCommandOptionTypes.BOOLEAN, - "required": false + name: "only_smol", + description: "Whether to show only baby animals", + type: Constants.ApplicationCommandOptionTypes.BOOLEAN, + required: false } ], - type: Constants.ApplicationCommandTypes.CHAT_INPUT //Not required for Chat input type, but recommended - }); //Create a chat input command + type: Constants.ApplicationCommandTypes.CHAT_INPUT // Not required for Chat input type, but recommended + }); // Create a chat input command bot.createCommand({ name: "Test User Menu", type: Constants.ApplicationCommandTypes.USER - }); //Create a user context menu + }); // Create a user context menu bot.createCommand({ name: "Test Message Menu", type: Constants.ApplicationCommandTypes.MESSAGE - }); //Create a message context menu + }); // Create a message context menu bot.createCommand({ name: "test_edit_command", description: "Test command to show off how to edit commands", - type: Constants.ApplicationCommandTypes.CHAT_INPUT //Not required for Chat input type, but recommended - }); //Create a chat input command + type: Constants.ApplicationCommandTypes.CHAT_INPUT // Not required for Chat input type, but recommended + }); // Create a chat input command bot.createCommand({ name: "test_delete_command", description: "Test command to show off how to delete commands", - type: Constants.ApplicationCommandTypes.CHAT_INPUT //Not required for Chat input type, but recommended - }); //Create a chat input command + type: Constants.ApplicationCommandTypes.CHAT_INPUT // Not required for Chat input type, but recommended + }); // Create a chat input command - //In practice, you should use bulkEditCommands if you need to create multiple commands + // In practice, you should use bulkEditCommands if you need to create multiple commands } }); diff --git a/index.d.ts b/index.d.ts index 2fe5a3da..e9f0b99d 100644 --- a/index.d.ts +++ b/index.d.ts @@ -161,7 +161,6 @@ declare namespace Dysnomia { type SelectMenuTypes = Constants["ComponentTypes"][keyof Pick]; type SelectMenuExtendedTypes = Constants["ComponentTypes"][keyof Pick]; - // Permission type PermissionType = Constants["PermissionOverwriteTypes"][keyof Constants["PermissionOverwriteTypes"]]; @@ -1883,6 +1882,7 @@ declare namespace Dysnomia { scopes: string[]; permissions: string; } + /* eslint-disable @stylistic/key-spacing, @stylistic/no-multi-spaces */ interface Constants { GATEWAY_VERSION: 10; REST_VERSION: 10; @@ -2504,7 +2504,7 @@ declare namespace Dysnomia { }; GuildScheduledEventStatus: { SCHEDULED: 1; - ACTIVE: 2; + ACTIVE: 2; COMPLETED: 3; CANCELED: 4; }; @@ -2522,6 +2522,7 @@ declare namespace Dysnomia { APPLICATION: 3; }; } + /* eslint-enable @stylistic/key-spacing, @stylistic/no-multi-spaces */ // Classes export class AutocompleteInteraction extends Interaction { @@ -2550,7 +2551,6 @@ declare namespace Dysnomia { delete(): Promise; edit(options: EditAutoModerationRuleOptions): Promise; - } export class Attachment extends Base { contentType?: string; @@ -3360,6 +3360,7 @@ declare namespace Dysnomia { : CH extends Exclude // Invite without Metadata ? Guild // If the invite channel is not partial : Guild | undefined; // If the invite channel is partial + // The event might not get included if not valid guildScheduledEvent: CT extends "withGuildScheduledEvent" ? GuildScheduledEvent | undefined : never; inviter?: User; diff --git a/lib/Client.js b/lib/Client.js index 2b5391ca..68187746 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -44,9 +44,9 @@ try { const sleep = (ms) => new Promise((res) => setTimeout(res, ms)); /** -* Represents the main Dysnomia client -* @extends EventEmitter -*/ + * Represents the main Dysnomia client + * @extends EventEmitter + */ class Client extends EventEmitter { /** * Object mapping channel IDs to guild IDs @@ -71,6 +71,7 @@ class Client extends EventEmitter { since: null, status: "offline" }; + /** * Object mapping user IDs to private channel IDs * @type {Object} @@ -120,49 +121,49 @@ class Client extends EventEmitter { */ /** - * Create a Client - * @arg {String} token The auth token to use. Bot tokens should be prefixed with `Bot` (e.g. `Bot MTExIHlvdSAgdHJpZWQgMTEx.O5rKAA.dQw4w9WgXcQ_wpV-gGA4PSk_bm8`). - * @arg {Object} options Dysnomia client options - * @arg {Object} [options.allowedMentions] A list of mentions to allow by default in createMessage/editMessage - * @arg {Boolean} [options.allowedMentions.everyone] Whether or not to allow @everyone/@here - * @arg {Boolean | Array} [options.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow - * @arg {Boolean | Array} [options.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow - * @arg {Boolean} [options.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to - * @arg {String} [options.defaultImageFormat="jpg"] The default format to provide user avatars, guild icons, and group icons in. Can be "jpg", "png", "gif", or "webp" - * @arg {Number} [options.defaultImageSize=128] The default size to return user avatars, guild icons, banners, splashes, and group icons. Can be any power of two between 16 and 2048. If the height and width are different, the width will be the value specified, and the height relative to that - * @arg {Object} [options.gateway] Options for gateway connections - * @arg {Boolean} [options.gateway.autoreconnect=true] Have Dysnomia autoreconnect when connection is lost - * @arg {Boolean} [options.gateway.compress=false] Whether to request WebSocket data to be compressed or not - * @arg {Number} [options.gateway.connectionTimeout=30000] How long in milliseconds to wait for the connection to handshake with the server - * @arg {Object} [options.gateway.disableEvents] If disableEvents[eventName] is true, the WS event will not be processed. This can cause significant performance increase on large bots. [A full list of the WS event names in Discord's documentation](https://discord.com/developers/docs/topics/gateway-events#receive-events) - * @arg {Number} [options.gateway.firstShardID=0] The ID of the first shard to run for this client - * @arg {Boolean} [options.gateway.getAllUsers=false] Get all the users in every guild. Ready time will be severely delayed - * @arg {Number} [options.gateway.guildCreateTimeout=2000] How long in milliseconds to wait for a GUILD_CREATE before "ready" is fired. Increase this value if you notice missing guilds - * @arg {Number | Array} [options.gateway.intents] A list of [intent names](https://github.com/projectdysnomia/dysnomia/blob/dev/lib/Constants.js#L311), pre-shifted intent numbers to add, or a raw bitmask value describing the intents to subscribe to. Some intents, like `guildPresences` and `guildMembers`, must be enabled on your application's page to be used. By default, all non-privileged intents are enabled. - * @arg {Number} [options.gateway.largeThreshold=250] The maximum number of offline users per guild during initial guild data transmission - * @arg {Number} [options.gateway.lastShardID=options.maxShards - 1] The ID of the last shard to run for this client - * @arg {Number} [options.gateway.maxReconnectAttempts=Infinity] The maximum amount of times that the client is allowed to try to reconnect to Discord. - * @arg {Number} [options.gateway.maxResumeAttempts=10] The maximum amount of times a shard can attempt to resume a session before considering that session invalid. - * @arg {Number | String} [options.gateway.maxConcurrency=1] The number of shards that can start simultaneously. If "auto" Dysnomia will use Discord's recommended shard concurrency. - * @arg {Number | String} [options.gateway.maxShards=1] The total number of shards you want to run. If "auto" Dysnomia will use Discord's recommended shard count. - * @arg {Function} [options.gateway.reconnectDelay] A function which returns how long the bot should wait until reconnecting to Discord. - * @arg {Boolean} [options.gateway.seedVoiceConnections=false] Whether to populate bot.voiceConnections with existing connections the bot account has during startup. Note that this will disconnect connections from other bot sessions - * @arg {Number} [options.messageLimit=100] The maximum size of a channel message cache - * @arg {Boolean} [options.opusOnly=false] Whether to suppress the Opus encoder not found error or not - * @arg {Object} [options.rest] Options for the REST request handler - * @arg {Object} [options.rest.agent] A HTTPS Agent (if https: true, default) or an HTTP agent (if https: false) used to proxy requests - * @arg {String} [options.rest.baseURL] The base URL to use for API requests. Defaults to `/api/v${REST_VERSION}` - * @arg {Boolean} [options.rest.disableLatencyCompensation=false] Whether to disable the built-in latency compensator or not - * @arg {String} [options.rest.domain="discord.com"] The domain to use for API requests - * @arg {Boolean} [options.rest.https=true] Whether to make requests to the Discord API over HTTPS (true) or HTTP (false) - * @arg {Number} [options.rest.latencyThreshold=30000] The average request latency at which Dysnomia will start emitting latency errors - * @arg {Number} [options.rest.port] The port to use for API requests. Defaults to 443 (HTTPS) or 80 (HTTP) - * @arg {Object} [options.rest.headers] Headers to be appended in REST requests - * @arg {Number} [options.rest.ratelimiterOffset=0] A number of milliseconds to offset the ratelimit timing calculations by - * @arg {Number} [options.rest.requestTimeout=15000] A number of milliseconds before REST requests are considered timed out - * @arg {Boolean} [options.restMode=false] Whether to enable getting objects over REST. Even with this option enabled, it is recommended that you check the cache first before using REST - * @arg {Object} [options.ws] An object of WebSocket options to pass to the shard WebSocket constructors - */ + * Create a Client + * @param {String} token The auth token to use. Bot tokens should be prefixed with `Bot` (e.g. `Bot MTExIHlvdSAgdHJpZWQgMTEx.O5rKAA.dQw4w9WgXcQ_wpV-gGA4PSk_bm8`). + * @param {Object} options Dysnomia client options + * @param {Object} [options.allowedMentions] A list of mentions to allow by default in createMessage/editMessage + * @param {Boolean} [options.allowedMentions.everyone] Whether or not to allow @everyone/@here + * @param {Boolean | Array} [options.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow + * @param {Boolean | Array} [options.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow + * @param {Boolean} [options.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to + * @param {String} [options.defaultImageFormat="jpg"] The default format to provide user avatars, guild icons, and group icons in. Can be "jpg", "png", "gif", or "webp" + * @param {Number} [options.defaultImageSize=128] The default size to return user avatars, guild icons, banners, splashes, and group icons. Can be any power of two between 16 and 2048. If the height and width are different, the width will be the value specified, and the height relative to that + * @param {Object} [options.gateway] Options for gateway connections + * @param {Boolean} [options.gateway.autoreconnect=true] Have Dysnomia autoreconnect when connection is lost + * @param {Boolean} [options.gateway.compress=false] Whether to request WebSocket data to be compressed or not + * @param {Number} [options.gateway.connectionTimeout=30000] How long in milliseconds to wait for the connection to handshake with the server + * @param {Object} [options.gateway.disableEvents] If disableEvents[eventName] is true, the WS event will not be processed. This can cause significant performance increase on large bots. [A full list of the WS event names in Discord's documentation](https://discord.com/developers/docs/topics/gateway-events#receive-events) + * @param {Number} [options.gateway.firstShardID=0] The ID of the first shard to run for this client + * @param {Boolean} [options.gateway.getAllUsers=false] Get all the users in every guild. Ready time will be severely delayed + * @param {Number} [options.gateway.guildCreateTimeout=2000] How long in milliseconds to wait for a GUILD_CREATE before "ready" is fired. Increase this value if you notice missing guilds + * @param {Number | Array} [options.gateway.intents] A list of [intent names](https://github.com/projectdysnomia/dysnomia/blob/dev/lib/Constants.js#L311), pre-shifted intent numbers to add, or a raw bitmask value describing the intents to subscribe to. Some intents, like `guildPresences` and `guildMembers`, must be enabled on your application's page to be used. By default, all non-privileged intents are enabled. + * @param {Number} [options.gateway.largeThreshold=250] The maximum number of offline users per guild during initial guild data transmission + * @param {Number} [options.gateway.lastShardID=options.maxShards - 1] The ID of the last shard to run for this client + * @param {Number} [options.gateway.maxReconnectAttempts=Infinity] The maximum amount of times that the client is allowed to try to reconnect to Discord. + * @param {Number} [options.gateway.maxResumeAttempts=10] The maximum amount of times a shard can attempt to resume a session before considering that session invalid. + * @param {Number | String} [options.gateway.maxConcurrency=1] The number of shards that can start simultaneously. If "auto" Dysnomia will use Discord's recommended shard concurrency. + * @param {Number | String} [options.gateway.maxShards=1] The total number of shards you want to run. If "auto" Dysnomia will use Discord's recommended shard count. + * @param {Function} [options.gateway.reconnectDelay] A function which returns how long the bot should wait until reconnecting to Discord. + * @param {Boolean} [options.gateway.seedVoiceConnections=false] Whether to populate bot.voiceConnections with existing connections the bot account has during startup. Note that this will disconnect connections from other bot sessions + * @param {Number} [options.messageLimit=100] The maximum size of a channel message cache + * @param {Boolean} [options.opusOnly=false] Whether to suppress the Opus encoder not found error or not + * @param {Object} [options.rest] Options for the REST request handler + * @param {Object} [options.rest.agent] A HTTPS Agent (if https: true, default) or an HTTP agent (if https: false) used to proxy requests + * @param {String} [options.rest.baseURL] The base URL to use for API requests. Defaults to `/api/v${REST_VERSION}` + * @param {Boolean} [options.rest.disableLatencyCompensation=false] Whether to disable the built-in latency compensator or not + * @param {String} [options.rest.domain="discord.com"] The domain to use for API requests + * @param {Boolean} [options.rest.https=true] Whether to make requests to the Discord API over HTTPS (true) or HTTP (false) + * @param {Number} [options.rest.latencyThreshold=30000] The average request latency at which Dysnomia will start emitting latency errors + * @param {Number} [options.rest.port] The port to use for API requests. Defaults to 443 (HTTPS) or 80 (HTTP) + * @param {Object} [options.rest.headers] Headers to be appended in REST requests + * @param {Number} [options.rest.ratelimiterOffset=0] A number of milliseconds to offset the ratelimit timing calculations by + * @param {Number} [options.rest.requestTimeout=15000] A number of milliseconds before REST requests are considered timed out + * @param {Boolean} [options.restMode=false] Whether to enable getting objects over REST. Even with this option enabled, it is recommended that you check the cache first before using REST + * @param {Object} [options.ws] An object of WebSocket options to pass to the shard WebSocket constructors + */ constructor(token, options) { super(); @@ -238,15 +239,15 @@ class Client extends EventEmitter { /** * Add a member to a guild - * @arg {String} guildID The ID of the guild - * @arg {String} userID The ID of the user - * @arg {String} accessToken The access token of the user - * @arg {Object} [options] Options for adding the member - * @arg {String} [options.nick] The nickname of the member - * @arg {Array} [options.roles] Array of role IDs to add to the member - * @arg {Boolean} [options.mute] Whether the member should be muted - * @arg {Boolean} [options.deaf] Whether the member should be deafened - * @return {Promise} + * @param {String} guildID The ID of the guild + * @param {String} userID The ID of the user + * @param {String} accessToken The access token of the user + * @param {Object} [options] Options for adding the member + * @param {String} [options.nick] The nickname of the member + * @param {Array} [options.roles] Array of role IDs to add to the member + * @param {Boolean} [options.mute] Whether the member should be muted + * @param {Boolean} [options.deaf] Whether the member should be deafened + * @returns {Promise} */ addGuildMember(guildID, userID, accessToken, options = {}) { return this.requestHandler.request("PUT", Endpoints.GUILD_MEMBER(guildID, userID), true, { @@ -259,13 +260,13 @@ class Client extends EventEmitter { } /** - * Add a role to a guild member - * @arg {String} guildID The ID of the guild - * @arg {String} memberID The ID of the member - * @arg {String} roleID The ID of the role - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Add a role to a guild member + * @param {String} guildID The ID of the guild + * @param {String} memberID The ID of the member + * @param {String} roleID The ID of the role + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ addGuildMemberRole(guildID, memberID, roleID, reason) { return this.requestHandler.request("PUT", Endpoints.GUILD_MEMBER_ROLE(guildID, memberID, roleID), true, { reason @@ -273,12 +274,12 @@ class Client extends EventEmitter { } /** - * Add a reaction to a message - * @arg {String} channelID The ID of the channel - * @arg {String} messageID The ID of the message - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @returns {Promise} - */ + * Add a reaction to a message + * @param {String} channelID The ID of the channel + * @param {String} messageID The ID of the message + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @returns {Promise} + */ addMessageReaction(channelID, messageID, reaction) { if(reaction === decodeURI(reaction)) { reaction = encodeURIComponent(reaction); @@ -287,13 +288,13 @@ class Client extends EventEmitter { } /** - * Ban a user from a guild - * @arg {String} guildID The ID of the guild - * @arg {String} userID The ID of the user - * @arg {Number} [options.deleteMessageSeconds=0] Number of seconds to delete messages for, between 0 and 604800 inclusive - * @arg {String} [options.reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Ban a user from a guild + * @param {String} guildID The ID of the guild + * @param {String} userID The ID of the user + * @param {Number} [options.deleteMessageSeconds=0] Number of seconds to delete messages for, between 0 and 604800 inclusive + * @param {String} [options.reason] The reason to be displayed in audit logs + * @returns {Promise} + */ banGuildMember(guildID, userID, options) { return this.requestHandler.request("PUT", Endpoints.GUILD_BAN(guildID, userID), true, { delete_message_seconds: options.deleteMessageSeconds || 0, @@ -303,10 +304,10 @@ class Client extends EventEmitter { /** * Ban multiple users from a guild - * @arg {String} guildID The ID of the guild - * @arg {Array} userIDs An array of user IDs to ban - * @arg {Number} [options.deleteMessageSeconds=0] Number of seconds to delete messages for, between 0 and 604800 inclusive - * @arg {String} [options.reason] The reason to be displayed in audit logs + * @param {String} guildID The ID of the guild + * @param {Array} userIDs An array of user IDs to ban + * @param {Number} [options.deleteMessageSeconds=0] Number of seconds to delete messages for, between 0 and 604800 inclusive + * @param {String} [options.reason] The reason to be displayed in audit logs * @returns {Promise<{ bannedUsers: Array, failedUsers: Array }>} A Promise resolving with an object containing an array of banned users and an array of users for whom the ban operation failed. In case banning all specified users fails, this promise rejects with an error.instead. */ bulkBanGuildMembers(guildID, userIDs, options = {}) { @@ -321,21 +322,21 @@ class Client extends EventEmitter { } /** - * Edits command permissions for a multiple commands in a guild. - * Note: You can only add up to 10 permission overwrites for a command. - * @arg {String} guildID The guild ID - * @arg {Array} permissions An array of [partial guild command permissions](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure) - * @returns {Promise>} Returns an array of [GuildApplicationCommandPermissions](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure) objects. - */ + * Edits command permissions for a multiple commands in a guild. + * Note: You can only add up to 10 permission overwrites for a command. + * @param {String} guildID The guild ID + * @param {Array} permissions An array of [partial guild command permissions](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure) + * @returns {Promise>} Returns an array of [GuildApplicationCommandPermissions](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure) objects. + */ bulkEditCommandPermissions(guildID, permissions) { return this.requestHandler.request("PUT", Endpoints.GUILD_COMMAND_PERMISSIONS(this.application.id, guildID), true, permissions); } /** - * Bulk create/edit global application commands - * @arg {Array} commands An array of [Command objects](https://discord.com/developers/docs/interactions/application-commands#application-command-object) - * @returns {Promise} - */ + * Bulk create/edit global application commands + * @param {Array} commands An array of [Command objects](https://discord.com/developers/docs/interactions/application-commands#application-command-object) + * @returns {Promise} + */ bulkEditCommands(commands) { for(const command of commands) { if(command.name !== undefined && command.type === 1) { @@ -353,11 +354,11 @@ class Client extends EventEmitter { } /** - * Bulk create/edit guild application commands - * @arg {String} guildID Guild id to create the commands in - * @arg {Array} commands An array of [Command objects](https://discord.com/developers/docs/interactions/application-commands#application-command-object) - * @returns {ApplicationCommand[]} Resolves with an array of commands objects - */ + * Bulk create/edit guild application commands + * @param {String} guildID Guild id to create the commands in + * @param {Array} commands An array of [Command objects](https://discord.com/developers/docs/interactions/application-commands#application-command-object) + * @returns {ApplicationCommand[]} Resolves with an array of commands objects + */ bulkEditGuildCommands(guildID, commands) { for(const command of commands) { if(command.name !== undefined && command.type === 1) { @@ -374,9 +375,9 @@ class Client extends EventEmitter { } /** - * Closes a voice connection with a guild ID - * @arg {String} guildID The ID of the guild - */ + * Closes a voice connection with a guild ID + * @param {String} guildID The ID of the guild + */ closeVoiceConnection(guildID) { this.shards.get(this.guildShardMap[guildID] || 0).sendWS(Constants.GatewayOPCodes.VOICE_STATE_UPDATE, { guild_id: guildID || null, @@ -388,9 +389,9 @@ class Client extends EventEmitter { } /** - * Tells all shards to connect. This will call `getBotGateway()`, which is ratelimited. - * @returns {Promise} Resolves when all shards are initialized - */ + * Tells all shards to connect. This will call `getBotGateway()`, which is ratelimited. + * @returns {Promise} Resolves when all shards are initialized + */ async connect() { if(typeof this._token !== "string") { throw new Error(`Invalid token "${this._token}"`); @@ -442,11 +443,12 @@ class Client extends EventEmitter { return this.connect(); } } + /** * Create an application emoji object - * @arg {Object} options Emoji options - * @arg {String} options.image The base 64 encoded string - * @arg {String} options.name The name of emoji + * @param {Object} options Emoji options + * @param {String} options.image The base 64 encoded string + * @param {String} options.name The name of emoji * @returns {Promise} An application emoji object */ createApplicationEmoji(options) { @@ -455,17 +457,17 @@ class Client extends EventEmitter { /** * Create an auto moderation rule - * @arg {String} guildID the ID of the guild to create the rule in - * @arg {Object} options The rule to create - * @arg {Object[]} options.actions The [actions](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object) done when the rule is violated - * @arg {Boolean} [options.enabled=false] If the rule is enabled, false by default - * @arg {Number} options.eventType The [event type](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-event-types) for the rule - * @arg {String[]} [options.exemptChannels] Any channels where this rule does not apply - * @arg {String[]} [options.exemptRoles] Any roles to which this rule does not apply - * @arg {String} options.name The name of the rule - * @arg {String} [options.reason] The reason to be displayed in audit logs - * @arg {Object} [options.triggerMetadata] The [trigger metadata](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-metadata) for the rule - * @arg {Number} options.triggerType The [trigger type](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-types) of the rule + * @param {String} guildID the ID of the guild to create the rule in + * @param {Object} options The rule to create + * @param {Object[]} options.actions The [actions](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object) done when the rule is violated + * @param {Boolean} [options.enabled=false] If the rule is enabled, false by default + * @param {Number} options.eventType The [event type](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-event-types) for the rule + * @param {String[]} [options.exemptChannels] Any channels where this rule does not apply + * @param {String[]} [options.exemptRoles] Any roles to which this rule does not apply + * @param {String} options.name The name of the rule + * @param {String} [options.reason] The reason to be displayed in audit logs + * @param {Object} [options.triggerMetadata] The [trigger metadata](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-metadata) for the rule + * @param {Number} options.triggerType The [trigger type](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-types) of the rule * @returns {Promise} */ createAutoModerationRule(guildID, options) { @@ -483,30 +485,30 @@ class Client extends EventEmitter { } /** - * Create a channel in a guild - * @arg {String} guildID The ID of the guild to create the channel in - * @arg {String} name The name of the channel - * @arg {String} [type=0] The type of the channel, either 0 (text), 2 (voice), 4 (category), 5 (news), 13 (stage), or 15 (forum) - * @arg {Object | String} [options] The properties the channel should have. - * @arg {Array} [options.availableTags] Available tags for a forum channel - * @arg {Number} [options.bitrate] The bitrate of the channel (voice channels only) - * @arg {Number} [options.defaultAutoArchiveDuration] The default duration of newly created threads in minutes to automatically archive the thread after inactivity (60, 1440, 4320, 10080) - * @arg {Number} [options.defaultForumLayout] The default forum layout view used to display forum posts - * @arg {Object} [options.defaultReactionEmoji] The emoji to show as the reaction button (forum channels only) - * @arg {Object} [options.defaultSortOrder] The default thread sorting order - * @arg {Number} [options.defaultThreadRateLimitPerUser] The initial ratelimit of the channel to use on newly created threads, in seconds. 0 means no ratelimit is enabled - * @arg {Boolean} [options.nsfw] The nsfw status of the channel - * @arg {String?} [options.parentID] The ID of the parent category channel for this channel - * @arg {Array} [options.permissionOverwrites] An array containing permission overwrite objects - * @arg {Number} [options.position] The sorting position of the channel - * @arg {Number} [options.rateLimitPerUser] The time in seconds a user has to wait before sending another message (does not affect bots or users with manageMessages/manageChannel permissions) (text channels only) - * @arg {String} [options.reason] The reason to be displayed in audit logs - * @arg {String} [options.rtcRegion] The RTC region ID of the channel (automatic if `null`) (voice channels only) - * @arg {String} [options.topic] The topic of the channel (text channels only) - * @arg {Number} [options.userLimit] The channel user limit (voice channels only) - * @arg {Number} [options.videoQualityMode] The camera video quality mode of the voice channel (voice channels only). `1` is auto, `2` is 720p - * @returns {Promise} - */ + * Create a channel in a guild + * @param {String} guildID The ID of the guild to create the channel in + * @param {String} name The name of the channel + * @param {String} [type=0] The type of the channel, either 0 (text), 2 (voice), 4 (category), 5 (news), 13 (stage), or 15 (forum) + * @param {Object | String} [options] The properties the channel should have. + * @param {Array} [options.availableTags] Available tags for a forum channel + * @param {Number} [options.bitrate] The bitrate of the channel (voice channels only) + * @param {Number} [options.defaultAutoArchiveDuration] The default duration of newly created threads in minutes to automatically archive the thread after inactivity (60, 1440, 4320, 10080) + * @param {Number} [options.defaultForumLayout] The default forum layout view used to display forum posts + * @param {Object} [options.defaultReactionEmoji] The emoji to show as the reaction button (forum channels only) + * @param {Object} [options.defaultSortOrder] The default thread sorting order + * @param {Number} [options.defaultThreadRateLimitPerUser] The initial ratelimit of the channel to use on newly created threads, in seconds. 0 means no ratelimit is enabled + * @param {Boolean} [options.nsfw] The nsfw status of the channel + * @param {String?} [options.parentID] The ID of the parent category channel for this channel + * @param {Array} [options.permissionOverwrites] An array containing permission overwrite objects + * @param {Number} [options.position] The sorting position of the channel + * @param {Number} [options.rateLimitPerUser] The time in seconds a user has to wait before sending another message (does not affect bots or users with manageMessages/manageChannel permissions) (text channels only) + * @param {String} [options.reason] The reason to be displayed in audit logs + * @param {String} [options.rtcRegion] The RTC region ID of the channel (automatic if `null`) (voice channels only) + * @param {String} [options.topic] The topic of the channel (text channels only) + * @param {Number} [options.userLimit] The channel user limit (voice channels only) + * @param {Number} [options.videoQualityMode] The camera video quality mode of the voice channel (voice channels only). `1` is auto, `2` is 720p + * @returns {Promise} + */ createChannel(guildID, name, type, options = {}) { return this.requestHandler.request("POST", Endpoints.GUILD_CHANNELS(guildID), true, { name: name, @@ -541,19 +543,19 @@ class Client extends EventEmitter { } /** - * Create an invite for a channel - * @arg {String} channelID The ID of the channel - * @arg {Object} [options] Invite generation options - * @arg {Number} [options.maxAge] How long the invite should last in seconds - * @arg {Number} [options.maxUses] How many uses the invite should last for - * @arg {String} [options.targetApplicationID] The target application id - * @arg {Number} [options.targetType] The type of the target application - * @arg {String} [options.targetUserID] The ID of the user whose stream should be displayed for the invite (`options.targetType` must be `1`) - * @arg {Boolean} [options.temporary] Whether the invite grants temporary membership or not - * @arg {Boolean} [options.unique] Whether the invite is unique or not - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Create an invite for a channel + * @param {String} channelID The ID of the channel + * @param {Object} [options] Invite generation options + * @param {Number} [options.maxAge] How long the invite should last in seconds + * @param {Number} [options.maxUses] How many uses the invite should last for + * @param {String} [options.targetApplicationID] The target application id + * @param {Number} [options.targetType] The type of the target application + * @param {String} [options.targetUserID] The ID of the user whose stream should be displayed for the invite (`options.targetType` must be `1`) + * @param {Boolean} [options.temporary] Whether the invite grants temporary membership or not + * @param {Boolean} [options.unique] Whether the invite is unique or not + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ createChannelInvite(channelID, options = {}, reason) { return this.requestHandler.request("POST", Endpoints.CHANNEL_INVITES(channelID), true, { max_age: options.maxAge, @@ -568,33 +570,33 @@ class Client extends EventEmitter { } /** - * Create a channel webhook - * @arg {String} channelID The ID of the channel to create the webhook in - * @arg {Object} options Webhook options - * @arg {String} options.name The default name - * @arg {String?} [options.avatar] The default avatar as a base64 data URI. Note: base64 strings alone are not base64 data URI strings - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} Resolves with a webhook object - */ + * Create a channel webhook + * @param {String} channelID The ID of the channel to create the webhook in + * @param {Object} options Webhook options + * @param {String} options.name The default name + * @param {String?} [options.avatar] The default avatar as a base64 data URI. Note: base64 strings alone are not base64 data URI strings + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} Resolves with a webhook object + */ createChannelWebhook(channelID, options, reason) { options.reason = reason; return this.requestHandler.request("POST", Endpoints.CHANNEL_WEBHOOKS(channelID), true, options); } /** - * Create a global application command - * @arg {Object} command A command object - * @arg {String} command.name The command name - * @arg {Number} command.type The [type](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types) of command - * @arg {Object} [command.nameLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to names for that locale - * @arg {String} [command.description] The command description (chat input commands only) - * @arg {Object} [command.descriptionLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to descriptions for that locale - * @arg {Boolean} [command.nsfw] Whether this command is age-restricted or not - * @arg {Array} [command.options] An array of [command options](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure) - * @arg {BigInt | Number | String | Permission} [command.defaultMemberPermissions] The default member [permissions](https://discord.com/developers/docs/topics/permissions) represented as a bit set - * @arg {Boolean} [command.dmPermission=true] If this command can be used in direct messages - * @returns {Promise} - */ + * Create a global application command + * @param {Object} command A command object + * @param {String} command.name The command name + * @param {Number} command.type The [type](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types) of command + * @param {Object} [command.nameLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to names for that locale + * @param {String} [command.description] The command description (chat input commands only) + * @param {Object} [command.descriptionLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to descriptions for that locale + * @param {Boolean} [command.nsfw] Whether this command is age-restricted or not + * @param {Array} [command.options] An array of [command options](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure) + * @param {BigInt | Number | String | Permission} [command.defaultMemberPermissions] The default member [permissions](https://discord.com/developers/docs/topics/permissions) represented as a bit set + * @param {Boolean} [command.dmPermission=true] If this command can be used in direct messages + * @returns {Promise} + */ createCommand(command) { if(command.name !== undefined && command.type === 1) { command.name = command.name.toLowerCase(); @@ -610,21 +612,21 @@ class Client extends EventEmitter { } /** - * Create a guild - * @arg {String} name The name of the guild - * @arg {Object} options The properties of the guild - * @arg {String} [options.afkChannelID] The ID of the AFK voice channel - * @arg {Number} [options.afkTimeout] The AFK timeout in seconds - * @arg {Array} [options.channels] The new channels of the guild. IDs are placeholders which allow use of category channels. - * @arg {Number} [options.defaultNotifications] The default notification settings for the guild. 0 is "All Messages", 1 is "Only @mentions". - * @arg {Number} [options.explicitContentFilter] The level of the explicit content filter for messages/images in the guild. 0 disables message scanning, 1 enables scanning the messages of members without roles, 2 enables scanning for all messages. - * @arg {String} [options.icon] The guild icon as a base64 data URI. Note: base64 strings alone are not base64 data URI strings - * @arg {Array} [options.roles] The new roles of the guild, the first one is the @everyone role. IDs are placeholders which allow channel overwrites. - * @arg {Number} [options.systemChannelFlags] The system channel flags - * @arg {String} [options.systemChannelID] The ID of the system channel - * @arg {Number} [options.verificationLevel] The guild verification level - * @returns {Promise} - */ + * Create a guild + * @param {String} name The name of the guild + * @param {Object} options The properties of the guild + * @param {String} [options.afkChannelID] The ID of the AFK voice channel + * @param {Number} [options.afkTimeout] The AFK timeout in seconds + * @param {Array} [options.channels] The new channels of the guild. IDs are placeholders which allow use of category channels. + * @param {Number} [options.defaultNotifications] The default notification settings for the guild. 0 is "All Messages", 1 is "Only @mentions". + * @param {Number} [options.explicitContentFilter] The level of the explicit content filter for messages/images in the guild. 0 disables message scanning, 1 enables scanning the messages of members without roles, 2 enables scanning for all messages. + * @param {String} [options.icon] The guild icon as a base64 data URI. Note: base64 strings alone are not base64 data URI strings + * @param {Array} [options.roles] The new roles of the guild, the first one is the @everyone role. IDs are placeholders which allow channel overwrites. + * @param {Number} [options.systemChannelFlags] The system channel flags + * @param {String} [options.systemChannelID] The ID of the system channel + * @param {Number} [options.verificationLevel] The guild verification level + * @returns {Promise} + */ createGuild(name, options) { if(this.guilds.size > 9) { throw new Error("This method can't be used when in 10 or more guilds."); @@ -646,19 +648,19 @@ class Client extends EventEmitter { } /** - * Create a guild application command - * @arg {String} guildID The ID of the guild to create the command in - * @arg {Object} command A command object - * @arg {String} command.name The command name - * @arg {Number} command.type The [type](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types) of command - * @arg {Object} [command.nameLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to names for that locale - * @arg {String} [command.description] The command description (chat input commands only) - * @arg {Object} [command.descriptionLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to descriptions for that locale - * @arg {Boolean} [command.nsfw] Whether this command is age-restricted or not - * @arg {Array} [command.options] An array of [command options](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure) - * @arg {BigInt | Number | String | Permission} [command.defaultMemberPermissions] The default member [permissions](https://discord.com/developers/docs/topics/permissions) represented as a bit set - * @returns {Promise} - */ + * Create a guild application command + * @param {String} guildID The ID of the guild to create the command in + * @param {Object} command A command object + * @param {String} command.name The command name + * @param {Number} command.type The [type](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types) of command + * @param {Object} [command.nameLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to names for that locale + * @param {String} [command.description] The command description (chat input commands only) + * @param {Object} [command.descriptionLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to descriptions for that locale + * @param {Boolean} [command.nsfw] Whether this command is age-restricted or not + * @param {Array} [command.options] An array of [command options](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure) + * @param {BigInt | Number | String | Permission} [command.defaultMemberPermissions] The default member [permissions](https://discord.com/developers/docs/topics/permissions) represented as a bit set + * @returns {Promise} + */ createGuildCommand(guildID, command) { if(command.name !== undefined && command.type === 1) { command.name = command.name.toLowerCase(); @@ -673,27 +675,27 @@ class Client extends EventEmitter { } /** - * Create a guild emoji object - * @arg {String} guildID The ID of the guild to create the emoji in - * @arg {Object} options Emoji options - * @arg {String} options.image The base 64 encoded string - * @arg {String} options.name The name of emoji - * @arg {Array} [options.roles] An array containing authorized role IDs - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} A guild emoji object - */ + * Create a guild emoji object + * @param {String} guildID The ID of the guild to create the emoji in + * @param {Object} options Emoji options + * @param {String} options.image The base 64 encoded string + * @param {String} options.name The name of emoji + * @param {Array} [options.roles] An array containing authorized role IDs + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} A guild emoji object + */ createGuildEmoji(guildID, options, reason) { options.reason = reason; return this.requestHandler.request("POST", Endpoints.GUILD_EMOJIS(guildID), true, options); } /** - * Create a guild based on a template. This can only be used with bots in less than 10 guilds - * @arg {String} code The template code - * @arg {String} name The name of the guild - * @arg {String} [icon] The 128x128 icon as a base64 data URI - * @returns {Promise} - */ + * Create a guild based on a template. This can only be used with bots in less than 10 guilds + * @param {String} code The template code + * @param {String} name The name of the guild + * @param {String} [icon] The 128x128 icon as a base64 data URI + * @returns {Promise} + */ createGuildFromTemplate(code, name, icon) { return this.requestHandler.request("POST", Endpoints.GUILD_TEMPLATE(code), true, { name, @@ -702,22 +704,22 @@ class Client extends EventEmitter { } /** - * Create a guild scheduled event - * @arg {String} guildID The guild ID where the event will be created - * @arg {Object} event The event to be created - * @arg {String} [event.channelID] The channel ID of the event. This is optional if `entityType` is `3` (external) - * @arg {String} [event.description] The description of the event - * @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event. This is required if `entityType` is `3` (external) - * @arg {String} [event.entityMetadata.location] Location of the event - * @arg {Number} event.entityType The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event - * @arg {String} [event.image] Base 64 encoded image for the scheduled event - * @arg {String} event.name The name of the event - * @arg {String} event.privacyLevel The privacy level of the event - * @arg {Date} [event.scheduledEndTime] The time when the event is scheduled to end. This is required if `entityType` is `3` (external) - * @arg {Date} event.scheduledStartTime The time the event will start - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Create a guild scheduled event + * @param {String} guildID The guild ID where the event will be created + * @param {Object} event The event to be created + * @param {String} [event.channelID] The channel ID of the event. This is optional if `entityType` is `3` (external) + * @param {String} [event.description] The description of the event + * @param {Object} [event.entityMetadata] The entity metadata for the scheduled event. This is required if `entityType` is `3` (external) + * @param {String} [event.entityMetadata.location] Location of the event + * @param {Number} event.entityType The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event + * @param {String} [event.image] Base 64 encoded image for the scheduled event + * @param {String} event.name The name of the event + * @param {String} event.privacyLevel The privacy level of the event + * @param {Date} [event.scheduledEndTime] The time when the event is scheduled to end. This is required if `entityType` is `3` (external) + * @param {Date} event.scheduledStartTime The time the event will start + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ createGuildScheduledEvent(guildID, event, reason) { return this.requestHandler.request("POST", Endpoints.GUILD_SCHEDULED_EVENTS(guildID), true, { channel_id: event.channelID, @@ -734,18 +736,18 @@ class Client extends EventEmitter { } /** - * Create a guild sticker - * @arg {String} guildID The guild to create a sticker in - * @arg {Object} options Sticker options - * @arg {String} options.description The description of the sticker - * @arg {Object} options.file A file object - * @arg {Buffer} options.file.file A buffer containing file data - * @arg {String} options.file.name What to name the file - * @arg {String} options.name The name of the sticker - * @arg {String} options.tags The Discord name of a unicode emoji representing the sticker's expression - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} A sticker object - */ + * Create a guild sticker + * @param {String} guildID The guild to create a sticker in + * @param {Object} options Sticker options + * @param {String} options.description The description of the sticker + * @param {Object} options.file A file object + * @param {Buffer} options.file.file A buffer containing file data + * @param {String} options.file.name What to name the file + * @param {String} options.name The name of the sticker + * @param {String} options.tags The Discord name of a unicode emoji representing the sticker's expression + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} A sticker object + */ createGuildSticker(guildID, options, reason) { return this.requestHandler.request("POST", Endpoints.GUILD_STICKERS(guildID), true, { description: options.description, @@ -759,12 +761,12 @@ class Client extends EventEmitter { } /** - * Create a template for a guild - * @arg {String} guildID The ID of the guild - * @arg {String} name The name of the template - * @arg {String} [description] The description for the template - * @returns {Promise} - */ + * Create a template for a guild + * @param {String} guildID The ID of the guild + * @param {String} name The name of the template + * @param {String} [description] The description for the template + * @returns {Promise} + */ createGuildTemplate(guildID, name, description) { return this.requestHandler.request("POST", Endpoints.GUILD_TEMPLATES(guildID), true, { name, @@ -773,53 +775,53 @@ class Client extends EventEmitter { } /** - * Respond to the interaction with a message - * Note: Use webhooks if you have already responded with an interaction response. - * @arg {String} interactionID The interaction ID. - * @arg {String} interactionToken The interaction Token. - * @arg {Object} options The options object. - * @arg {Object} [options.data] The data to send with the response. **WARNING: This call expects raw API data and does not transform it in any way.** - * @arg {Number} options.type The response type to send. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type) for valid types - * @arg {Object | Array} [file] A file object (or an Array of them) - * @arg {String} [file.fieldName] The multipart field name - * @arg {Buffer} file.file A buffer containing file data - * @arg {String} file.name What to name the file - * @returns {Promise} - */ + * Respond to the interaction with a message + * Note: Use webhooks if you have already responded with an interaction response. + * @param {String} interactionID The interaction ID. + * @param {String} interactionToken The interaction Token. + * @param {Object} options The options object. + * @param {Object} [options.data] The data to send with the response. **WARNING: This call expects raw API data and does not transform it in any way.** + * @param {Number} options.type The response type to send. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type) for valid types + * @param {Object | Array} [file] A file object (or an Array of them) + * @param {String} [file.fieldName] The multipart field name + * @param {Buffer} file.file A buffer containing file data + * @param {String} file.name What to name the file + * @returns {Promise} + */ createInteractionResponse(interactionID, interactionToken, options, file) { return this.requestHandler.request("POST", Endpoints.INTERACTION_RESPOND(interactionID, interactionToken), true, options, file, "/interactions/:id/:token/callback"); } /** - * Create a message in a channel - * Note: If you want to DM someone, the user ID is **not** the DM channel ID. use Client.getDMChannel() to get the DM channel for a user - * @arg {String} channelID The ID of the channel - * @arg {String | Object} content A string or object. If an object is passed: - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. - * @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {Buffer} content.attachments[].file A buffer containing file data - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Boolean} [content.enforceNonce] If set and nonce is present, check the message for uniqueness in the past few minutes - * @arg {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {Number} [content.flags] Message flags. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list - * @arg {Object} [content.messageReference] The message reference, used when replying to messages - * @arg {String} [content.messageReference.channelID] The channel ID of the referenced message - * @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message - * @arg {String} [content.messageReference.guildID] The guild ID of the referenced message - * @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message - * @arg {String | Number} [content.nonce] A value that can be used to check if the message was sent - * @arg {Object} [content.poll] A poll object. See [Discord's Documentation](https://discord.com/developers/docs/resources/poll#poll-create-request-object-poll-create-request-object-structure) for object structure - * @arg {Array} [content.stickerIDs] An array of IDs corresponding to stickers to send - * @arg {Boolean} [content.tts] Set the message TTS flag - * @returns {Promise} - */ + * Create a message in a channel + * Note: If you want to DM someone, the user ID is **not** the DM channel ID. use Client.getDMChannel() to get the DM channel for a user + * @param {String} channelID The ID of the channel + * @param {String | Object} content A string or object. If an object is passed: + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. + * @param {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. + * @param {Array} [content.attachments] The files to attach to the message + * @param {Buffer} content.attachments[].file A buffer containing file data + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Boolean} [content.enforceNonce] If set and nonce is present, check the message for uniqueness in the past few minutes + * @param {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {Number} [content.flags] Message flags. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list + * @param {Object} [content.messageReference] The message reference, used when replying to messages + * @param {String} [content.messageReference.channelID] The channel ID of the referenced message + * @param {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message + * @param {String} [content.messageReference.guildID] The guild ID of the referenced message + * @param {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message + * @param {String | Number} [content.nonce] A value that can be used to check if the message was sent + * @param {Object} [content.poll] A poll object. See [Discord's Documentation](https://discord.com/developers/docs/resources/poll#poll-create-request-object-poll-create-request-object-structure) for object structure + * @param {Array} [content.stickerIDs] An array of IDs corresponding to stickers to send + * @param {Boolean} [content.tts] Set the message TTS flag + * @returns {Promise} + */ createMessage(channelID, content) { if(content !== undefined) { if(typeof content !== "object" || content === null) { @@ -860,19 +862,19 @@ class Client extends EventEmitter { } /** - * Create a guild role - * @arg {String} guildID The ID of the guild to create the role in - * @arg {Object | Role} [options] An object or Role containing the properties to set - * @arg {Number} [options.color] The hex color of the role, in number form (ex: 0x3d15b3 or 4040115) - * @arg {Boolean} [options.hoist] Whether to hoist the role in the user list or not - * @arg {String} [options.icon] The role icon as a base64 data URI - * @arg {Boolean} [options.mentionable] Whether the role is mentionable or not - * @arg {String} [options.name] The name of the role - * @arg {BigInt | Number | String | Permission} [options.permissions] The role permissions - * @arg {String} [options.unicodeEmoji] The role's unicode emoji - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Create a guild role + * @param {String} guildID The ID of the guild to create the role in + * @param {Object | Role} [options] An object or Role containing the properties to set + * @param {Number} [options.color] The hex color of the role, in number form (ex: 0x3d15b3 or 4040115) + * @param {Boolean} [options.hoist] Whether to hoist the role in the user list or not + * @param {String} [options.icon] The role icon as a base64 data URI + * @param {Boolean} [options.mentionable] Whether the role is mentionable or not + * @param {String} [options.name] The name of the role + * @param {BigInt | Number | String | Permission} [options.permissions] The role permissions + * @param {String} [options.unicodeEmoji] The role's unicode emoji + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ createRole(guildID, options, reason) { if(options.permissions !== undefined) { options.permissions = options.permissions instanceof Permission ? String(options.permissions.allow) : String(options.permissions); @@ -897,15 +899,15 @@ class Client extends EventEmitter { } /** - * Create a stage instance - * @arg {String} channelID The ID of the stage channel to create the instance in - * @arg {Object} options The stage instance options - * @arg {String} [options.guildScheduledEventID] The ID of the guild scheduled event associated with the stage instance - * @arg {Number} [options.privacyLevel] The privacy level of the stage instance. 1 is public (deprecated), 2 is guild only - * @arg {Boolean} [options.sendStartNotification] Whether to notify @everyone that a stage instance has started or not - * @arg {String} options.topic The stage instance topic - * @returns {Promise} - */ + * Create a stage instance + * @param {String} channelID The ID of the stage channel to create the instance in + * @param {Object} options The stage instance options + * @param {String} [options.guildScheduledEventID] The ID of the guild scheduled event associated with the stage instance + * @param {Number} [options.privacyLevel] The privacy level of the stage instance. 1 is public (deprecated), 2 is guild only + * @param {Boolean} [options.sendStartNotification] Whether to notify @everyone that a stage instance has started or not + * @param {String} options.topic The stage instance topic + * @returns {Promise} + */ createStageInstance(channelID, options) { return this.requestHandler.request("POST", Endpoints.STAGE_INSTANCES, true, { channel_id: channelID, @@ -917,30 +919,30 @@ class Client extends EventEmitter { } /** - * Create a thread in a channel - * @arg {String} channelID The ID of the channel - * @arg {Object} options The thread options - * @arg {Number} [options.autoArchiveDuration] Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080 - * @arg {Array} [options.appliedTags] The tags to apply to the thread (available only in threads in thread-only channels) - * @arg {Boolean} [options.invitable] Whether non-moderators can add other non-moderators to the thread (private threads only) - * @arg {Object} [options.message] The message to attach to the thread (set only if creating a thread in a thread-only channel) - * @arg {Object} [options.message.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [options.message.allowedMentions.everyone] Whether or not to allow @everyone/@here. - * @arg {Boolean | Array} [options.message.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. - * @arg {Boolean | Array} [options.message.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. - * @arg {Array} [options.message.attachments] The files to attach to the message - * @arg {Buffer} options.message.attachments[].file A buffer containing file data - * @arg {String} options.message.attachments[].filename What to name the file - * @arg {String} [options.message.attachments[].description] A description for the attachment - * @arg {Array} [options.message.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [options.message.content] A content string - * @arg {Array} [options.message.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {Array} [options.message.stickerIDs] An array of IDs corresponding to stickers to send - * @arg {String} options.name The thread channel name - * @arg {Number} [options.type] The channel type of the thread to create. It is recommended to explicitly set this property as this will be a required property in API v10 - * @arg {Number} [options.rateLimitPerUser] The ratelimit of the channel, in seconds. 0 means no ratelimit is enabled - * @returns {Promise} - */ + * Create a thread in a channel + * @param {String} channelID The ID of the channel + * @param {Object} options The thread options + * @param {Number} [options.autoArchiveDuration] Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080 + * @param {Array} [options.appliedTags] The tags to apply to the thread (available only in threads in thread-only channels) + * @param {Boolean} [options.invitable] Whether non-moderators can add other non-moderators to the thread (private threads only) + * @param {Object} [options.message] The message to attach to the thread (set only if creating a thread in a thread-only channel) + * @param {Object} [options.message.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [options.message.allowedMentions.everyone] Whether or not to allow @everyone/@here. + * @param {Boolean | Array} [options.message.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. + * @param {Boolean | Array} [options.message.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. + * @param {Array} [options.message.attachments] The files to attach to the message + * @param {Buffer} options.message.attachments[].file A buffer containing file data + * @param {String} options.message.attachments[].filename What to name the file + * @param {String} [options.message.attachments[].description] A description for the attachment + * @param {Array} [options.message.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [options.message.content] A content string + * @param {Array} [options.message.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {Array} [options.message.stickerIDs] An array of IDs corresponding to stickers to send + * @param {String} options.name The thread channel name + * @param {Number} [options.type] The channel type of the thread to create. It is recommended to explicitly set this property as this will be a required property in API v10 + * @param {Number} [options.rateLimitPerUser] The ratelimit of the channel, in seconds. 0 means no ratelimit is enabled + * @returns {Promise} + */ createThread(channelID, options) { if(options.message) { if(options.message.content !== undefined && typeof options.message.content !== "string") { @@ -967,15 +969,15 @@ class Client extends EventEmitter { } /** - * Create a thread with an existing message - * @arg {String} channelID The ID of the channel - * @arg {String} messageID The ID of the message to create the thread from - * @arg {Object} options The thread options - * @arg {Number} [options.autoArchiveDuration] Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080 - * @arg {String} options.name The thread channel name - * @arg {Number} [options.rateLimitPerUser] The ratelimit of the channel, in seconds. 0 means no ratelimit is enabled - * @returns {Promise} - */ + * Create a thread with an existing message + * @param {String} channelID The ID of the channel + * @param {String} messageID The ID of the message to create the thread from + * @param {Object} options The thread options + * @param {Number} [options.autoArchiveDuration] Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080 + * @param {String} options.name The thread channel name + * @param {Number} [options.rateLimitPerUser] The ratelimit of the channel, in seconds. 0 means no ratelimit is enabled + * @returns {Promise} + */ createThreadWithMessage(channelID, messageID, options) { return this.requestHandler.request("POST", Endpoints.THREAD_WITH_MESSAGE(channelID, messageID), true, { name: options.name, @@ -986,8 +988,8 @@ class Client extends EventEmitter { /** * Crosspost (publish) a message to subscribed channels - * @arg {String} channelID The ID of the NewsChannel - * @arg {String} messageID The ID of the message + * @param {String} channelID The ID of the NewsChannel + * @param {String} messageID The ID of the message * @returns {Promise} */ crosspostMessage(channelID, messageID) { @@ -995,19 +997,19 @@ class Client extends EventEmitter { } /** - * Delete an application emoji object - * @arg {String} emojiID The ID of the emoji - * @returns {Promise} - */ + * Delete an application emoji object + * @param {String} emojiID The ID of the emoji + * @returns {Promise} + */ deleteApplicationEmoji(emojiID) { return this.requestHandler.request("DELETE", Endpoints.APPLICATION_EMOJI(this.application.id, emojiID), true); } /** * Delete an auto moderation rule - * @arg {String} guildID The guildID to delete the rule from - * @arg {String} ruleID The ID of the rule to delete - * @arg {String} [reason] The reason to be displayed in audit logs + * @param {String} guildID The guildID to delete the rule from + * @param {String} ruleID The ID of the rule to delete + * @param {String} [reason] The reason to be displayed in audit logs * @returns {Promise} */ deleteAutoModerationRule(guildID, ruleID, reason) { @@ -1017,11 +1019,11 @@ class Client extends EventEmitter { } /** - * Delete a guild channel, or leave a private channel - * @arg {String} channelID The ID of the channel - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Delete a guild channel, or leave a private channel + * @param {String} channelID The ID of the channel + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ deleteChannel(channelID, reason) { return this.requestHandler.request("DELETE", Endpoints.CHANNEL(channelID), true, { reason @@ -1029,12 +1031,12 @@ class Client extends EventEmitter { } /** - * Delete a channel permission overwrite - * @arg {String} channelID The ID of the channel - * @arg {String} overwriteID The ID of the overwritten user or role - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Delete a channel permission overwrite + * @param {String} channelID The ID of the channel + * @param {String} overwriteID The ID of the overwritten user or role + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ deleteChannelPermission(channelID, overwriteID, reason) { return this.requestHandler.request("DELETE", Endpoints.CHANNEL_PERMISSION(channelID, overwriteID), true, { reason @@ -1042,40 +1044,40 @@ class Client extends EventEmitter { } /** - * Delete a global application command - * @arg {String} commandID The command id - * @returns {Promise} - */ + * Delete a global application command + * @param {String} commandID The command id + * @returns {Promise} + */ deleteCommand(commandID) { return this.requestHandler.request("DELETE", Endpoints.COMMAND(this.application.id, commandID), true); } /** - * Delete a guild (bot user must be owner) - * @arg {String} guildID The ID of the guild - * @returns {Promise} - */ + * Delete a guild (bot user must be owner) + * @param {String} guildID The ID of the guild + * @returns {Promise} + */ deleteGuild(guildID) { return this.requestHandler.request("DELETE", Endpoints.GUILD(guildID), true); } /** - * Delete a guild application command - * @arg {String} guildID The guild ID - * @arg {String} commandID The command id - * @returns {Promise} - */ + * Delete a guild application command + * @param {String} guildID The guild ID + * @param {String} commandID The command id + * @returns {Promise} + */ deleteGuildCommand(guildID, commandID) { return this.requestHandler.request("DELETE", Endpoints.GUILD_COMMAND(this.application.id, guildID, commandID), true); } /** - * Delete a guild emoji object - * @arg {String} guildID The ID of the guild to delete the emoji in - * @arg {String} emojiID The ID of the emoji - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Delete a guild emoji object + * @param {String} guildID The ID of the guild to delete the emoji in + * @param {String} emojiID The ID of the emoji + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ deleteGuildEmoji(guildID, emojiID, reason) { return this.requestHandler.request("DELETE", Endpoints.GUILD_EMOJI(guildID, emojiID), true, { reason @@ -1083,32 +1085,32 @@ class Client extends EventEmitter { } /** - * Delete a guild integration - * @arg {String} guildID The ID of the guild - * @arg {String} integrationID The ID of the integration - * @returns {Promise} - */ + * Delete a guild integration + * @param {String} guildID The ID of the guild + * @param {String} integrationID The ID of the integration + * @returns {Promise} + */ deleteGuildIntegration(guildID, integrationID) { return this.requestHandler.request("DELETE", Endpoints.GUILD_INTEGRATION(guildID, integrationID), true); } /** - * Delete a guild scheduled event - * @arg {String} guildID The ID of the guild - * @arg {String} eventID The ID of the event - * @returns {Promise} - */ + * Delete a guild scheduled event + * @param {String} guildID The ID of the guild + * @param {String} eventID The ID of the event + * @returns {Promise} + */ deleteGuildScheduledEvent(guildID, eventID) { return this.requestHandler.request("DELETE", Endpoints.GUILD_SCHEDULED_EVENT(guildID, eventID), true); } /** - * Delete a guild sticker - * @arg {String} guildID The ID of the guild - * @arg {String} stickerID The ID of the sticker - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Delete a guild sticker + * @param {String} guildID The ID of the guild + * @param {String} stickerID The ID of the sticker + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ deleteGuildSticker(guildID, stickerID, reason) { return this.requestHandler.request("DELETE", Endpoints.GUILD_STICKER(guildID, stickerID), true, { reason @@ -1116,21 +1118,21 @@ class Client extends EventEmitter { } /** - * Delete a guild template - * @arg {String} guildID The ID of the guild - * @arg {String} code The template code - * @returns {Promise} - */ + * Delete a guild template + * @param {String} guildID The ID of the guild + * @param {String} code The template code + * @returns {Promise} + */ deleteGuildTemplate(guildID, code) { return this.requestHandler.request("DELETE", Endpoints.GUILD_TEMPLATE_GUILD(guildID, code), true).then((template) => new GuildTemplate(template, this)); } /** - * Delete an invite - * @arg {String} inviteID The ID of the invite - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Delete an invite + * @param {String} inviteID The ID of the invite + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ deleteInvite(inviteID, reason) { return this.requestHandler.request("DELETE", Endpoints.INVITE(inviteID), true, { reason @@ -1138,12 +1140,12 @@ class Client extends EventEmitter { } /** - * Delete a message - * @arg {String} channelID The ID of the channel - * @arg {String} messageID The ID of the message - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Delete a message + * @param {String} channelID The ID of the channel + * @param {String} messageID The ID of the message + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ deleteMessage(channelID, messageID, reason) { return this.requestHandler.request("DELETE", Endpoints.CHANNEL_MESSAGE(channelID, messageID), true, { reason @@ -1151,12 +1153,12 @@ class Client extends EventEmitter { } /** - * Bulk delete messages - * @arg {String} channelID The ID of the channel - * @arg {Array} messageIDs Array of message IDs to delete - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Bulk delete messages + * @param {String} channelID The ID of the channel + * @param {Array} messageIDs Array of message IDs to delete + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ deleteMessages(channelID, messageIDs, reason) { if(messageIDs.length === 0) { return Promise.resolve(); @@ -1184,12 +1186,12 @@ class Client extends EventEmitter { } /** - * Delete a guild role - * @arg {String} guildID The ID of the guild to create the role in - * @arg {String} roleID The ID of the role - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Delete a guild role + * @param {String} guildID The ID of the guild to create the role in + * @param {String} roleID The ID of the role + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ deleteRole(guildID, roleID, reason) { return this.requestHandler.request("DELETE", Endpoints.GUILD_ROLE(guildID, roleID), true, { reason @@ -1197,21 +1199,21 @@ class Client extends EventEmitter { } /** - * Delete a stage instance - * @arg {String} channelID The stage channel associated with the instance - * @returns {Promise} - */ + * Delete a stage instance + * @param {String} channelID The stage channel associated with the instance + * @returns {Promise} + */ deleteStageInstance(channelID) { return this.requestHandler.request("DELETE", Endpoints.STAGE_INSTANCE(channelID), true); } /** - * Delete a webhook - * @arg {String} webhookID The ID of the webhook - * @arg {String} [token] The token of the webhook, used instead of the Bot Authorization token - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Delete a webhook + * @param {String} webhookID The ID of the webhook + * @param {String} [token] The token of the webhook, used instead of the Bot Authorization token + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ deleteWebhook(webhookID, token, reason) { return this.requestHandler.request("DELETE", token ? Endpoints.WEBHOOK_TOKEN(webhookID, token) : Endpoints.WEBHOOK(webhookID), !token, { reason @@ -1219,13 +1221,13 @@ class Client extends EventEmitter { } /** - * Delete a webhook message - * @arg {String} webhookID The ID of the webhook - * @arg {String} token The token of the webhook - * @arg {String} messageID The ID of the message - * @arg {String} [threadID] The ID of the thread channel if the message is in a thread - * @returns {Promise} - */ + * Delete a webhook message + * @param {String} webhookID The ID of the webhook + * @param {String} token The token of the webhook + * @param {String} messageID The ID of the message + * @param {String} [threadID] The ID of the thread channel if the message is in a thread + * @returns {Promise} + */ deleteWebhookMessage(webhookID, token, messageID, threadID) { return this.requestHandler.request("DELETE", Endpoints.WEBHOOK_MESSAGE(webhookID, token, messageID), false, { thread_id: threadID @@ -1233,10 +1235,10 @@ class Client extends EventEmitter { } /** - * Disconnects all shards - * @arg {Object?} [options] Shard disconnect options - * @arg {String | Boolean} [options.reconnect] false means destroy everything, true means you want to reconnect in the future, "auto" will autoreconnect - */ + * Disconnects all shards + * @param {Object?} [options] Shard disconnect options + * @param {String | Boolean} [options.reconnect] false means destroy everything, true means you want to reconnect in the future, "auto" will autoreconnect + */ disconnect(options) { this.ready = false; this.shards.forEach((shard) => { @@ -1246,9 +1248,9 @@ class Client extends EventEmitter { } /** - * Update the bot's AFK status. Setting this to true will enable push notifications for userbots. - * @arg {Boolean} afk Whether the bot user is AFK or not - */ + * Update the bot's AFK status. Setting this to true will enable push notifications for userbots. + * @param {Boolean} afk Whether the bot user is AFK or not + */ editAFK(afk) { this.presence.afk = !!afk; @@ -1267,29 +1269,29 @@ class Client extends EventEmitter { } /** - * Edit an application emoji object - * @arg {String} emojiID The ID of the emoji you want to modify - * @arg {Object} options Emoji options - * @arg {String} [options.name] The name of emoji - * @returns {Promise} An application emoji object - */ + * Edit an application emoji object + * @param {String} emojiID The ID of the emoji you want to modify + * @param {Object} options Emoji options + * @param {String} [options.name] The name of emoji + * @returns {Promise} An application emoji object + */ editApplicationEmoji(emojiID, options) { return this.requestHandler.request("PATCH", Endpoints.APPLICATION_EMOJI(this.application.id, emojiID), true, options); } /** * Edit an existing auto moderation rule - * @arg {String} guildID the ID of the guild to edit the rule in - * @arg {String} ruleID The ID of the rule to edit - * @arg {Object} options The new rule options - * @arg {Object[]} [options.actions] The [actions](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object) done when the rule is violated - * @arg {Boolean} [options.enabled=false] If the rule is enabled, false by default - * @arg {Number} [options.eventType] The [event type](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-event-types) for the rule - * @arg {String[]} [options.exemptChannels] Any channels where this rule does not apply - * @arg {String[]} [options.exemptRoles] Any roles to which this rule does not apply - * @arg {String} [options.name] The name of the rule - * @arg {String} [options.reason] The reason to be displayed in audit logs - * @arg {Object} [options.triggerMetadata] The [trigger metadata](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-metadata) for the rule + * @param {String} guildID the ID of the guild to edit the rule in + * @param {String} ruleID The ID of the rule to edit + * @param {Object} options The new rule options + * @param {Object[]} [options.actions] The [actions](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object) done when the rule is violated + * @param {Boolean} [options.enabled=false] If the rule is enabled, false by default + * @param {Number} [options.eventType] The [event type](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-event-types) for the rule + * @param {String[]} [options.exemptChannels] Any channels where this rule does not apply + * @param {String[]} [options.exemptRoles] Any roles to which this rule does not apply + * @param {String} [options.name] The name of the rule + * @param {String} [options.reason] The reason to be displayed in audit logs + * @param {Object} [options.triggerMetadata] The [trigger metadata](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-metadata) for the rule * @returns {Promise} */ editAutoModerationRule(guildID, ruleID, options) { @@ -1306,35 +1308,35 @@ class Client extends EventEmitter { } /** - * Edit a channel's properties - * @arg {String} channelID The ID of the channel - * @arg {Object} options The properties to edit - * @arg {Boolean} [options.archived] The archive status of the channel (thread channels only) - * @arg {Array} [options.appliedTags] An array of applied tag IDs for the thread (available only in threads in thread-only channels) - * @arg {Number} [options.autoArchiveDuration] The duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080 (thread channels only) - * @arg {Array} [options.availableTags] Available tags for a forum channel - * @arg {Number} [options.bitrate] The bitrate of the channel (guild voice channels only) - * @arg {Number?} [options.defaultAutoArchiveDuration] The default duration of newly created threads in minutes to automatically archive the thread after inactivity (60, 1440, 4320, 10080) (guild text/news channels only) - * @arg {Number} [options.defaultForumLayout] The default forum layout view used to display forum posts - * @arg {Object} [options.defaultReactionEmoji] The emoji to show as the reaction button (forum channels only) - * @arg {Number} [options.defaultSortOrder] The default thread sorting order - * @arg {Number} [options.defaultThreadRateLimitPerUser] The initial ratelimit of the channel to use on newly created threads, in seconds. 0 means no ratelimit is enabled - * @arg {Number} [options.flags] The channel flags - * @arg {Boolean} [options.invitable] Whether non-moderators can add other non-moderators to the channel (private thread channels only) - * @arg {Boolean} [options.locked] The lock status of the channel (thread channels only) - * @arg {String} [options.name] The name of the channel - * @arg {Boolean} [options.nsfw] The nsfw status of the channel (guild channels only) - * @arg {String?} [options.parentID] The ID of the parent channel category for this channel (guild text/voice channels only) - * @arg {Array} [options.permissionOverwrites] An array containing permission overwrite objects - * @arg {Number} [options.position] The sorting position of the channel (guild channels only) - * @arg {Number} [options.rateLimitPerUser] The time in seconds a user has to wait before sending another message (does not affect bots or users with manageMessages/manageChannel permissions) (guild text and thread channels only) - * @arg {String?} [options.rtcRegion] The RTC region ID of the channel (automatic if `null`) (guild voice channels only) - * @arg {String} [options.topic] The topic of the channel (guild text channels only) - * @arg {Number} [options.userLimit] The channel user limit (guild voice channels only) - * @arg {Number} [options.videoQualityMode] The camera video quality mode of the channel (guild voice channels only). `1` is auto, `2` is 720p - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Edit a channel's properties + * @param {String} channelID The ID of the channel + * @param {Object} options The properties to edit + * @param {Boolean} [options.archived] The archive status of the channel (thread channels only) + * @param {Array} [options.appliedTags] An array of applied tag IDs for the thread (available only in threads in thread-only channels) + * @param {Number} [options.autoArchiveDuration] The duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080 (thread channels only) + * @param {Array} [options.availableTags] Available tags for a forum channel + * @param {Number} [options.bitrate] The bitrate of the channel (guild voice channels only) + * @param {Number?} [options.defaultAutoArchiveDuration] The default duration of newly created threads in minutes to automatically archive the thread after inactivity (60, 1440, 4320, 10080) (guild text/news channels only) + * @param {Number} [options.defaultForumLayout] The default forum layout view used to display forum posts + * @param {Object} [options.defaultReactionEmoji] The emoji to show as the reaction button (forum channels only) + * @param {Number} [options.defaultSortOrder] The default thread sorting order + * @param {Number} [options.defaultThreadRateLimitPerUser] The initial ratelimit of the channel to use on newly created threads, in seconds. 0 means no ratelimit is enabled + * @param {Number} [options.flags] The channel flags + * @param {Boolean} [options.invitable] Whether non-moderators can add other non-moderators to the channel (private thread channels only) + * @param {Boolean} [options.locked] The lock status of the channel (thread channels only) + * @param {String} [options.name] The name of the channel + * @param {Boolean} [options.nsfw] The nsfw status of the channel (guild channels only) + * @param {String?} [options.parentID] The ID of the parent channel category for this channel (guild text/voice channels only) + * @param {Array} [options.permissionOverwrites] An array containing permission overwrite objects + * @param {Number} [options.position] The sorting position of the channel (guild channels only) + * @param {Number} [options.rateLimitPerUser] The time in seconds a user has to wait before sending another message (does not affect bots or users with manageMessages/manageChannel permissions) (guild text and thread channels only) + * @param {String?} [options.rtcRegion] The RTC region ID of the channel (automatic if `null`) (guild voice channels only) + * @param {String} [options.topic] The topic of the channel (guild text channels only) + * @param {Number} [options.userLimit] The channel user limit (guild voice channels only) + * @param {Number} [options.videoQualityMode] The camera video quality mode of the channel (guild voice channels only). `1` is auto, `2` is 720p + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ editChannel(channelID, options, reason) { return this.requestHandler.request("PATCH", Endpoints.CHANNEL(channelID), true, { archived: options.archived, @@ -1376,15 +1378,15 @@ class Client extends EventEmitter { } /** - * Create a channel permission overwrite - * @arg {String} channelID The ID of channel - * @arg {String} overwriteID The ID of the overwritten user or role (everyone role ID = guild ID) - * @arg {BigInt} allow The permissions number for allowed permissions - * @arg {BigInt} deny The permissions number for denied permissions - * @arg {Number} type The object type of the overwrite, either 1 for "member" or 0 for "role" - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Create a channel permission overwrite + * @param {String} channelID The ID of channel + * @param {String} overwriteID The ID of the overwritten user or role (everyone role ID = guild ID) + * @param {BigInt} allow The permissions number for allowed permissions + * @param {BigInt} deny The permissions number for denied permissions + * @param {Number} type The object type of the overwrite, either 1 for "member" or 0 for "role" + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ editChannelPermission(channelID, overwriteID, allow, deny, type, reason) { if(typeof type === "string") { // backward compatibility type = type === "member" ? 1 : 0; @@ -1398,14 +1400,14 @@ class Client extends EventEmitter { } /** - * Edit a guild channel's position. Note that channel position numbers are grouped by type (category, text, voice), then sorted in ascending order (lowest number is on top). - * @arg {String} channelID The ID of the channel - * @arg {Number} position The new position of the channel - * @arg {Object} [options] Additional options when editing position - * @arg {Boolean} [options.lockPermissions] Whether to sync the channel's permissions with the new parent, if changing parents - * @arg {String} [options.parentID] The new parent ID (category channel) for the channel that is moved - * @returns {Promise} - */ + * Edit a guild channel's position. Note that channel position numbers are grouped by type (category, text, voice), then sorted in ascending order (lowest number is on top). + * @param {String} channelID The ID of the channel + * @param {Number} position The new position of the channel + * @param {Object} [options] Additional options when editing position + * @param {Boolean} [options.lockPermissions] Whether to sync the channel's permissions with the new parent, if changing parents + * @param {String} [options.parentID] The new parent ID (category channel) for the channel that is moved + * @returns {Promise} + */ editChannelPosition(channelID, position, options = {}) { let channels = this.guilds.get(this.channelGuildMap[channelID]).channels; const channel = channels.get(channelID); @@ -1437,15 +1439,15 @@ class Client extends EventEmitter { } /** - * Edit multiple guild channels' positions. Note that channel position numbers are grouped by type (category, text, voice), then sorted in ascending order (lowest number is on top). - * @arg {String} guildID The ID of the guild - * @arg {Array} channelPositions An array of [ChannelPosition](https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions) - * @arg {String} channelPositions[].id The ID of the channel - * @arg {Number} [channelPositions[].position] The new position of the channel - * @arg {Boolean} [channelPositions[].lockPermissions] Whether to sync the channel's permissions with the new parent, if changing parents - * @arg {String} [channelPositions[].parentID] The new parent ID (category channel) for the channel that is moved. For each request, only one channel can change parents - * @returns {Promise} - */ + * Edit multiple guild channels' positions. Note that channel position numbers are grouped by type (category, text, voice), then sorted in ascending order (lowest number is on top). + * @param {String} guildID The ID of the guild + * @param {Array} channelPositions An array of [ChannelPosition](https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions) + * @param {String} channelPositions[].id The ID of the channel + * @param {Number} [channelPositions[].position] The new position of the channel + * @param {Boolean} [channelPositions[].lockPermissions] Whether to sync the channel's permissions with the new parent, if changing parents + * @param {String} [channelPositions[].parentID] The new parent ID (category channel) for the channel that is moved. For each request, only one channel can change parents + * @returns {Promise} + */ editChannelPositions(guildID, channelPositions) { return this.requestHandler.request("PATCH", Endpoints.GUILD_CHANNELS(guildID), true, channelPositions.map((channelPosition) => { return { @@ -1458,19 +1460,19 @@ class Client extends EventEmitter { } /** - * Edit a global application command - * @arg {String} commandID The command id - * @arg {Object} command A command object - * @arg {String} [command.name] The command name - * @arg {Object} [command.nameLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to names for that locale - * @arg {String} [command.description] The command description (chat input commands only) - * @arg {Object} [command.descriptionLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to descriptions for that locale - * @arg {Array} [command.options] An array of [command options](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure) - * @arg {bigint | number | string | Permission} [command.defaultMemberPermissions] The default member [permissions](https://discord.com/developers/docs/topics/permissions) represented as a bit set - * @arg {String} [command.defaultMemberPermissions] The [permissions](https://discord.com/developers/docs/topics/permissions) required by default for this command to be usable - * @arg {Boolean} [command.dmPermission] If this command can be used in direct messages - * @returns {Promise} - */ + * Edit a global application command + * @param {String} commandID The command id + * @param {Object} command A command object + * @param {String} [command.name] The command name + * @param {Object} [command.nameLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to names for that locale + * @param {String} [command.description] The command description (chat input commands only) + * @param {Object} [command.descriptionLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to descriptions for that locale + * @param {Array} [command.options] An array of [command options](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure) + * @param {bigint | number | string | Permission} [command.defaultMemberPermissions] The default member [permissions](https://discord.com/developers/docs/topics/permissions) represented as a bit set + * @param {String} [command.defaultMemberPermissions] The [permissions](https://discord.com/developers/docs/topics/permissions) required by default for this command to be usable + * @param {Boolean} [command.dmPermission] If this command can be used in direct messages + * @returns {Promise} + */ editCommand(commandID, command) { if(command.name !== undefined && command.type === 1) { command.name = command.name.toLowerCase(); @@ -1486,44 +1488,44 @@ class Client extends EventEmitter { } /** - * Edits command permissions for a specific command in a guild. - * Note: You can only add up to 10 permission overwrites for a command. - * @arg {String} guildID The guild ID - * @arg {String} commandID The command id - * @arg {Array} permissions An array of [permissions objects](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-structure) - * @returns {Promise} Resolves with a [GuildApplicationCommandPermissions](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure) object. - */ + * Edits command permissions for a specific command in a guild. + * Note: You can only add up to 10 permission overwrites for a command. + * @param {String} guildID The guild ID + * @param {String} commandID The command id + * @param {Array} permissions An array of [permissions objects](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-structure) + * @returns {Promise} Resolves with a [GuildApplicationCommandPermissions](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure) object. + */ editCommandPermissions(guildID, commandID, permissions) { return this.requestHandler.request("PUT", Endpoints.COMMAND_PERMISSIONS(this.application.id, guildID, commandID), true, {permissions}); } /** - * Edit a guild - * @arg {String} guildID The ID of the guild - * @arg {Object} options The properties to edit - * @arg {String} [options.afkChannelID] The ID of the AFK voice channel - * @arg {Number} [options.afkTimeout] The AFK timeout in seconds - * @arg {String} [options.banner] The guild banner image as a base64 data URI (VIP only). Note: base64 strings alone are not base64 data URI strings - * @arg {Number} [options.defaultNotifications] The default notification settings for the guild. 0 is "All Messages", 1 is "Only @mentions". - * @arg {String} [options.description] The description for the guild (VIP only) - * @arg {String} [options.discoverySplash] The guild discovery splash image as a base64 data URI (VIP only). Note: base64 strings alone are not base64 data URI strings - * @arg {Number} [options.explicitContentFilter] The level of the explicit content filter for messages/images in the guild. 0 disables message scanning, 1 enables scanning the messages of members without roles, 2 enables scanning for all messages. - * @arg {Array} [options.features] The enabled features for the guild. Note that only certain features can be toggled with the API - * @arg {String} [options.icon] The guild icon as a base64 data URI. Note: base64 strings alone are not base64 data URI strings - * @arg {String} [options.name] The name of the guild - * @arg {String} [options.ownerID] The ID of the user to transfer server ownership to (bot user must be owner) - * @arg {String} [options.preferredLocale] Preferred "COMMUNITY" guild language used in server discovery and notices from Discord, and sent in interactions - * @arg {Boolean} [options.premiumProgressBarEnabled] If the boost progress bar is enabled - * @arg {String} [options.publicUpdatesChannelID] The id of the channel where admins and moderators of "COMMUNITY" guilds receive notices from Discord - * @arg {String} [options.rulesChannelID] The id of the channel where "COMMUNITY" guilds display rules and/or guidelines - * @arg {String} [options.safetyAlertsChannelID] The ID of the channel where safety alerts from Discord are received - * @arg {String} [options.splash] The guild splash image as a base64 data URI (VIP only). Note: base64 strings alone are not base64 data URI strings - * @arg {Number} [options.systemChannelFlags] The flags for the system channel - * @arg {String} [options.systemChannelID] The ID of the system channel - * @arg {Number} [options.verificationLevel] The guild verification level - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Edit a guild + * @param {String} guildID The ID of the guild + * @param {Object} options The properties to edit + * @param {String} [options.afkChannelID] The ID of the AFK voice channel + * @param {Number} [options.afkTimeout] The AFK timeout in seconds + * @param {String} [options.banner] The guild banner image as a base64 data URI (VIP only). Note: base64 strings alone are not base64 data URI strings + * @param {Number} [options.defaultNotifications] The default notification settings for the guild. 0 is "All Messages", 1 is "Only @mentions". + * @param {String} [options.description] The description for the guild (VIP only) + * @param {String} [options.discoverySplash] The guild discovery splash image as a base64 data URI (VIP only). Note: base64 strings alone are not base64 data URI strings + * @param {Number} [options.explicitContentFilter] The level of the explicit content filter for messages/images in the guild. 0 disables message scanning, 1 enables scanning the messages of members without roles, 2 enables scanning for all messages. + * @param {Array} [options.features] The enabled features for the guild. Note that only certain features can be toggled with the API + * @param {String} [options.icon] The guild icon as a base64 data URI. Note: base64 strings alone are not base64 data URI strings + * @param {String} [options.name] The name of the guild + * @param {String} [options.ownerID] The ID of the user to transfer server ownership to (bot user must be owner) + * @param {String} [options.preferredLocale] Preferred "COMMUNITY" guild language used in server discovery and notices from Discord, and sent in interactions + * @param {Boolean} [options.premiumProgressBarEnabled] If the boost progress bar is enabled + * @param {String} [options.publicUpdatesChannelID] The id of the channel where admins and moderators of "COMMUNITY" guilds receive notices from Discord + * @param {String} [options.rulesChannelID] The id of the channel where "COMMUNITY" guilds display rules and/or guidelines + * @param {String} [options.safetyAlertsChannelID] The ID of the channel where safety alerts from Discord are received + * @param {String} [options.splash] The guild splash image as a base64 data URI (VIP only). Note: base64 strings alone are not base64 data URI strings + * @param {Number} [options.systemChannelFlags] The flags for the system channel + * @param {String} [options.systemChannelID] The ID of the system channel + * @param {Number} [options.verificationLevel] The guild verification level + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ editGuild(guildID, options, reason) { return this.requestHandler.request("PATCH", Endpoints.GUILD(guildID), true, { name: options.name, @@ -1551,17 +1553,17 @@ class Client extends EventEmitter { } /** - * Edit a guild application command - * @arg {String} guildID The guild ID - * @arg {Object} command A command object - * @arg {String} [command.name] The command name - * @arg {Object} [command.nameLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to names for that locale - * @arg {String} [command.description] The command description (chat input commands only) - * @arg {Object} [command.descriptionLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to descriptions for that locale - * @arg {Array} [command.options] An array of [command options](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure) - * @arg {bigint | number | string | Permission} [command.defaultMemberPermissions] The default member [permissions](https://discord.com/developers/docs/topics/permissions) represented as a bit set - * @returns {Promise} - */ + * Edit a guild application command + * @param {String} guildID The guild ID + * @param {Object} command A command object + * @param {String} [command.name] The command name + * @param {Object} [command.nameLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to names for that locale + * @param {String} [command.description] The command description (chat input commands only) + * @param {Object} [command.descriptionLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to descriptions for that locale + * @param {Array} [command.options] An array of [command options](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure) + * @param {bigint | number | string | Permission} [command.defaultMemberPermissions] The default member [permissions](https://discord.com/developers/docs/topics/permissions) represented as a bit set + * @returns {Promise} + */ editGuildCommand(guildID, commandID, command) { if(command.name !== undefined && command.type === 1) { command.name = command.name.toLowerCase(); @@ -1576,35 +1578,35 @@ class Client extends EventEmitter { } /** - * Edit a guild emoji object - * @arg {String} guildID The ID of the guild to edit the emoji in - * @arg {String} emojiID The ID of the emoji you want to modify - * @arg {Object} options Emoji options - * @arg {String} [options.name] The name of emoji - * @arg {Array} [options.roles] An array containing authorized role IDs - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} A guild emoji object - */ + * Edit a guild emoji object + * @param {String} guildID The ID of the guild to edit the emoji in + * @param {String} emojiID The ID of the emoji you want to modify + * @param {Object} options Emoji options + * @param {String} [options.name] The name of emoji + * @param {Array} [options.roles] An array containing authorized role IDs + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} A guild emoji object + */ editGuildEmoji(guildID, emojiID, options, reason) { options.reason = reason; return this.requestHandler.request("PATCH", Endpoints.GUILD_EMOJI(guildID, emojiID), true, options); } /** - * Edit a guild member - * @arg {String} guildID The ID of the guild - * @arg {String} memberID The ID of the member (you can use "@me" if you are only editing the bot user's nickname) - * @arg {Object} options The properties to edit - * @arg {String?} [options.channelID] The ID of the voice channel to move the member to (must be in voice). Set to `null` to disconnect the member - * @arg {Date?} [options.communicationDisabledUntil] When the user's timeout should expire. Set to `null` to instantly remove timeout - * @arg {Boolean} [options.deaf] Server deafen the member - * @arg {Number} [options.flags] The guild member flag bit set - * @arg {Boolean} [options.mute] Server mute the member - * @arg {String} [options.nick] Set the member's server nickname, "" to remove - * @arg {Array} [options.roles] The array of role IDs the member should have - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Edit a guild member + * @param {String} guildID The ID of the guild + * @param {String} memberID The ID of the member (you can use "@me" if you are only editing the bot user's nickname) + * @param {Object} options The properties to edit + * @param {String?} [options.channelID] The ID of the voice channel to move the member to (must be in voice). Set to `null` to disconnect the member + * @param {Date?} [options.communicationDisabledUntil] When the user's timeout should expire. Set to `null` to instantly remove timeout + * @param {Boolean} [options.deaf] Server deafen the member + * @param {Number} [options.flags] The guild member flag bit set + * @param {Boolean} [options.mute] Server mute the member + * @param {String} [options.nick] Set the member's server nickname, "" to remove + * @param {Array} [options.roles] The array of role IDs the member should have + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ editGuildMember(guildID, memberID, options, reason) { return this.requestHandler.request("PATCH", Endpoints.GUILD_MEMBER(guildID, memberID), true, { roles: options.roles?.filter((roleID, index) => options.roles.indexOf(roleID) === index), @@ -1642,24 +1644,24 @@ class Client extends EventEmitter { } /** - * Edit a guild scheduled event - * @arg {String} guildID The guild ID where the event will be edited - * @arg {String} eventID The guild scheduled event ID to be edited - * @arg {Object} event The new guild scheduled event object - * @arg {String} [event.channelID] The channel ID of the event. If updating `entityType` to `3` (external), this **must** be set to `null` - * @arg {String} [event.description] The description of the event - * @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event. This is required if updating `entityType` to `3` (external) - * @arg {String} [event.entityMetadata.location] Location of the event. This is required if updating `entityType` to `3` (external) - * @arg {Number} [event.entityType] The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event - * @arg {String} [event.image] Base 64 encoded image for the event - * @arg {String} [event.name] The name of the event - * @arg {String} [event.privacyLevel] The privacy level of the event - * @arg {Date} [event.scheduledEndTime] The time when the scheduled event is scheduled to end. This is required if updating `entityType` to `3` (external) - * @arg {Date} [event.scheduledStartTime] The time the event will start - * @arg {Number} [event.status] The [status](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status) of the scheduled event - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Edit a guild scheduled event + * @param {String} guildID The guild ID where the event will be edited + * @param {String} eventID The guild scheduled event ID to be edited + * @param {Object} event The new guild scheduled event object + * @param {String} [event.channelID] The channel ID of the event. If updating `entityType` to `3` (external), this **must** be set to `null` + * @param {String} [event.description] The description of the event + * @param {Object} [event.entityMetadata] The entity metadata for the scheduled event. This is required if updating `entityType` to `3` (external) + * @param {String} [event.entityMetadata.location] Location of the event. This is required if updating `entityType` to `3` (external) + * @param {Number} [event.entityType] The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event + * @param {String} [event.image] Base 64 encoded image for the event + * @param {String} [event.name] The name of the event + * @param {String} [event.privacyLevel] The privacy level of the event + * @param {Date} [event.scheduledEndTime] The time when the scheduled event is scheduled to end. This is required if updating `entityType` to `3` (external) + * @param {Date} [event.scheduledStartTime] The time the event will start + * @param {Number} [event.status] The [status](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status) of the scheduled event + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ editGuildScheduledEvent(guildID, eventID, event, reason) { return this.requestHandler.request("PATCH", Endpoints.GUILD_SCHEDULED_EVENT(guildID, eventID), true, { channel_id: event.channelID, @@ -1677,43 +1679,43 @@ class Client extends EventEmitter { } /** - * Edit a guild sticker - * @arg {String} stickerID The ID of the sticker - * @arg {Object} options The properties to edit - * @arg {String} [options.description] The description of the sticker - * @arg {String} [options.name] The name of the sticker - * @arg {String} [options.tags] The Discord name of a unicode emoji representing the sticker's expression - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} A sticker object - */ + * Edit a guild sticker + * @param {String} stickerID The ID of the sticker + * @param {Object} options The properties to edit + * @param {String} [options.description] The description of the sticker + * @param {String} [options.name] The name of the sticker + * @param {String} [options.tags] The Discord name of a unicode emoji representing the sticker's expression + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} A sticker object + */ editGuildSticker(guildID, stickerID, options, reason) { options.reason = reason; return this.requestHandler.request("PATCH", Endpoints.GUILD_STICKER(guildID, stickerID), true, options); } /** - * Edit a guild template - * @arg {String} guildID The ID of the guild - * @arg {String} code The template code - * @arg {Object} options The properties to edit - * @arg {String} [options.name] The name of the template - * @arg {String?} [options.description] The description for the template. Set to `null` to remove the description - * @returns {Promise} - */ + * Edit a guild template + * @param {String} guildID The ID of the guild + * @param {String} code The template code + * @param {Object} options The properties to edit + * @param {String} [options.name] The name of the template + * @param {String?} [options.description] The description for the template. Set to `null` to remove the description + * @returns {Promise} + */ editGuildTemplate(guildID, code, options) { return this.requestHandler.request("PATCH", Endpoints.GUILD_TEMPLATE_GUILD(guildID, code), true, options).then((template) => new GuildTemplate(template, this)); } /** - * Update a user's voice state - See [caveats](https://discord.com/developers/docs/resources/guild#modify-user-voice-state-caveats) - * @arg {String} guildID The ID of the guild - * @arg {Object} options The properties to edit - * @arg {String} options.channelID The ID of the channel the user is currently in - * @arg {Date?} [options.requestToSpeakTimestamp] Sets the user's request to speak - this can only be used when the `userID` param is "@me" - * @arg {Boolean} [options.suppress] Toggles the user's suppress state - * @arg {String} [userID="@me"] The user ID of the user to update - * @returns {Promise} - */ + * Update a user's voice state - See [caveats](https://discord.com/developers/docs/resources/guild#modify-user-voice-state-caveats) + * @param {String} guildID The ID of the guild + * @param {Object} options The properties to edit + * @param {String} options.channelID The ID of the channel the user is currently in + * @param {Date?} [options.requestToSpeakTimestamp] Sets the user's request to speak - this can only be used when the `userID` param is "@me" + * @param {Boolean} [options.suppress] Toggles the user's suppress state + * @param {String} [userID="@me"] The user ID of the user to update + * @returns {Promise} + */ editGuildVoiceState(guildID, options, userID = "@me") { return this.requestHandler.request("PATCH", Endpoints.GUILD_VOICE_STATE(guildID, userID), true, { channel_id: options.channelID, @@ -1723,18 +1725,18 @@ class Client extends EventEmitter { } /** - * Edit a guild welcome screen - * @arg {String} guildID The ID of the guild - * @arg {Object} [options] The properties to edit - * @arg {String?} [options.description] The description in the welcome screen - * @arg {Boolean} [options.enabled] Whether the welcome screen is enabled - * @arg {Array} [options.welcomeChannels] The list of channels in the welcome screen as an array - * @arg {String} options.welcomeChannels[].channelID The channel ID of the welcome channel - * @arg {String} options.welcomeChannels[].description The description of the welcome channel - * @arg {String?} options.welcomeChannels[].emojiID The emoji ID of the welcome channel - * @arg {String?} options.welcomeChannels[].emojiName The emoji name of the welcome channel - * @returns {Promise} - */ + * Edit a guild welcome screen + * @param {String} guildID The ID of the guild + * @param {Object} [options] The properties to edit + * @param {String?} [options.description] The description in the welcome screen + * @param {Boolean} [options.enabled] Whether the welcome screen is enabled + * @param {Array} [options.welcomeChannels] The list of channels in the welcome screen as an array + * @param {String} options.welcomeChannels[].channelID The channel ID of the welcome channel + * @param {String} options.welcomeChannels[].description The description of the welcome channel + * @param {String?} options.welcomeChannels[].emojiID The emoji ID of the welcome channel + * @param {String?} options.welcomeChannels[].emojiName The emoji name of the welcome channel + * @returns {Promise} + */ editGuildWelcomeScreen(guildID, options) { return this.requestHandler.request("PATCH", Endpoints.GUILD_WELCOME_SCREEN(guildID), true, { description: options.description, @@ -1751,38 +1753,38 @@ class Client extends EventEmitter { } /** - * Modify a guild's widget - * @arg {String} guildID The ID of the guild - * @arg {Object} options The widget object to modify (https://discord.com/developers/docs/resources/guild#modify-guild-widget) - * @arg {Boolean} [options.enabled] Whether the guild widget is enabled - * @arg {String?} [options.channel_id] The channel ID for the guild widget - * @arg {String?} [options.reason] The reason to be displayed in audit logs - * @returns {Promise} A guild widget object - */ + * Modify a guild's widget + * @param {String} guildID The ID of the guild + * @param {Object} options The widget object to modify (https://discord.com/developers/docs/resources/guild#modify-guild-widget) + * @param {Boolean} [options.enabled] Whether the guild widget is enabled + * @param {String?} [options.channel_id] The channel ID for the guild widget + * @param {String?} [options.reason] The reason to be displayed in audit logs + * @returns {Promise} A guild widget object + */ editGuildWidget(guildID, options) { return this.requestHandler.request("PATCH", Endpoints.GUILD_WIDGET_SETTINGS(guildID), true, options); } /** - * Edit a message - * @arg {String} channelID The ID of the channel - * @arg {String} messageID The ID of the message - * @arg {String | Array | Object} content A string, array of strings, or object. If an object is passed: - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) - * @arg {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {Number} [content.flags] A number representing the flags to apply to the message. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list - * @returns {Promise} - */ + * Edit a message + * @param {String} channelID The ID of the channel + * @param {String} messageID The ID of the message + * @param {String | Array | Object} content A string, array of strings, or object. If an object is passed: + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. + * @param {Array} [content.attachments] The files to attach to the message + * @param {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) + * @param {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {Number} [content.flags] A number representing the flags to apply to the message. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list + * @returns {Promise} + */ editMessage(channelID, messageID, content) { if(content !== undefined) { if(typeof content !== "object" || content === null) { @@ -1804,20 +1806,20 @@ class Client extends EventEmitter { } /** - * Edit a guild role - * @arg {String} guildID The ID of the guild the role is in - * @arg {String} roleID The ID of the role - * @arg {Object} options The properties to edit - * @arg {Number} [options.color] The hex color of the role, in number form (ex: 0x3da5b3 or 4040115) - * @arg {Boolean} [options.hoist] Whether to hoist the role in the user list or not - * @arg {String} [options.icon] The role icon as a base64 data URI - * @arg {Boolean} [options.mentionable] Whether the role is mentionable or not - * @arg {String} [options.name] The name of the role - * @arg {BigInt | Number | String | Permission} [options.permissions] The role permissions - * @arg {String} [options.unicodeEmoji] The role's unicode emoji - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Edit a guild role + * @param {String} guildID The ID of the guild the role is in + * @param {String} roleID The ID of the role + * @param {Object} options The properties to edit + * @param {Number} [options.color] The hex color of the role, in number form (ex: 0x3da5b3 or 4040115) + * @param {Boolean} [options.hoist] Whether to hoist the role in the user list or not + * @param {String} [options.icon] The role icon as a base64 data URI + * @param {Boolean} [options.mentionable] Whether the role is mentionable or not + * @param {String} [options.name] The name of the role + * @param {BigInt | Number | String | Permission} [options.permissions] The role permissions + * @param {String} [options.unicodeEmoji] The role's unicode emoji + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ editRole(guildID, roleID, options, reason) { options.unicode_emoji = options.unicodeEmoji; options.reason = reason; @@ -1845,12 +1847,12 @@ class Client extends EventEmitter { } /** - * Edit a guild role's position. Note that role position numbers are highest on top and lowest at the bottom. - * @arg {String} guildID The ID of the guild the role is in - * @arg {String} roleID The ID of the role - * @arg {Number} position The new position of the role - * @returns {Promise} - */ + * Edit a guild role's position. Note that role position numbers are highest on top and lowest at the bottom. + * @param {String} guildID The ID of the guild the role is in + * @param {String} roleID The ID of the role + * @param {Number} position The new position of the role + * @returns {Promise} + */ editRolePosition(guildID, roleID, position) { if(guildID === roleID) { return Promise.reject(new Error("Cannot move default role")); @@ -1878,38 +1880,38 @@ class Client extends EventEmitter { } /** - * Edit properties of the bot user - * @arg {Object} options The properties to edit - * @arg {String} [options.username] The new username - * @arg {String?} [options.avatar] The new avatar as a base64 data URI. Note: base64 strings alone are not base64 data URI strings - * @arg {String?} [options.banner] The new banner as a base64 data URI. Note: base64 strings alone are not base64 data URI strings - * @returns {Promise} - */ + * Edit properties of the bot user + * @param {Object} options The properties to edit + * @param {String} [options.username] The new username + * @param {String?} [options.avatar] The new avatar as a base64 data URI. Note: base64 strings alone are not base64 data URI strings + * @param {String?} [options.banner] The new banner as a base64 data URI. Note: base64 strings alone are not base64 data URI strings + * @returns {Promise} + */ editSelf(options) { return this.requestHandler.request("PATCH", Endpoints.USER("@me"), true, options).then((data) => new ExtendedUser(data, this)); } /** - * Update a stage instance - * @arg {String} channelID The ID of the stage channel associated with the instance - * @arg {Object} options The properties to edit - * @arg {Number} [options.privacyLevel] The privacy level of the stage instance. 1 is public (deprecated), 2 is guild only - * @arg {String} [options.topic] The stage instance topic - * @returns {Promise} - */ + * Update a stage instance + * @param {String} channelID The ID of the stage channel associated with the instance + * @param {Object} options The properties to edit + * @param {Number} [options.privacyLevel] The privacy level of the stage instance. 1 is public (deprecated), 2 is guild only + * @param {String} [options.topic] The stage instance topic + * @returns {Promise} + */ editStageInstance(channelID, options) { return this.requestHandler.request("PATCH", Endpoints.STAGE_INSTANCE(channelID), true, options).then((instance) => new StageInstance(instance, this)); } /** - * Update the bot's status on all guilds - * @arg {String} [status] Sets the bot's status, either "online", "idle", "dnd", or "invisible" - * @arg {Array | Object} [activities] Sets the bot's activities. A single activity object is also accepted for backwards compatibility - * @arg {String} activities[].name The name of the activity - * @arg {Number} activities[].type The type of the activity. 0 is playing, 1 is streaming (Twitch only), 2 is listening, 3 is watching, 4 is custom status, 5 is competing in - * @arg {String} [activities[].url] The URL of the activity - * @arg {String} [activities[].state] The state of the activity - if using a custom status, this is the text to be shown to the users - */ + * Update the bot's status on all guilds + * @param {String} [status] Sets the bot's status, either "online", "idle", "dnd", or "invisible" + * @param {Array | Object} [activities] Sets the bot's activities. A single activity object is also accepted for backwards compatibility + * @param {String} activities[].name The name of the activity + * @param {Number} activities[].type The type of the activity. 0 is playing, 1 is streaming (Twitch only), 2 is listening, 3 is watching, 4 is custom status, 5 is competing in + * @param {String} [activities[].url] The URL of the activity + * @param {String} [activities[].state] The state of the activity - if using a custom status, this is the text to be shown to the users + */ editStatus(status, activities) { if(activities === undefined && typeof status === "object") { activities = status; @@ -1933,16 +1935,16 @@ class Client extends EventEmitter { } /** - * Edit a webhook - * @arg {String} webhookID The ID of the webhook - * @arg {Object} options Webhook options - * @arg {String} [options.name] The new default name - * @arg {String?} [options.avatar] The new default avatar as a base64 data URI. Note: base64 strings alone are not base64 data URI strings - * @arg {String} [options.channelID] The new channel ID where webhooks should be sent to - * @arg {String} [token] The token of the webhook, used instead of the Bot Authorization token - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} Resolves with a webhook object - */ + * Edit a webhook + * @param {String} webhookID The ID of the webhook + * @param {Object} options Webhook options + * @param {String} [options.name] The new default name + * @param {String?} [options.avatar] The new default avatar as a base64 data URI. Note: base64 strings alone are not base64 data URI strings + * @param {String} [options.channelID] The new channel ID where webhooks should be sent to + * @param {String} [token] The token of the webhook, used instead of the Bot Authorization token + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} Resolves with a webhook object + */ editWebhook(webhookID, options, token, reason) { return this.requestHandler.request("PATCH", token ? Endpoints.WEBHOOK_TOKEN(webhookID, token) : Endpoints.WEBHOOK(webhookID), !token, { name: options.name, @@ -1953,27 +1955,27 @@ class Client extends EventEmitter { } /** - * Edit a webhook message - * @arg {String} webhookID The ID of the webhook - * @arg {String} token The token of the webhook - * @arg {String} messageID The ID of the message - * @arg {Object} options Webhook message edit options - * @arg {Object} [options.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [options.allowedMentions.everyone] Whether or not to allow @everyone/@here. - * @arg {Boolean} [options.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. - * @arg {Boolean | Array} [options.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. - * @arg {Boolean | Array} [options.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. - * @arg {Array} [options.attachments] The files to attach to the message - * @arg {String} options.attachments[].id The ID of an attachment (set only when you want to update an attachment) - * @arg {Buffer} options.attachments[].file A buffer containing file data (set only when uploading new files) - * @arg {String} options.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [options.content] A content string - * @arg {Array} [options.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {String} [options.threadID] The ID of the thread channel in the webhook's channel to edit the message in - * @returns {Promise} - */ + * Edit a webhook message + * @param {String} webhookID The ID of the webhook + * @param {String} token The token of the webhook + * @param {String} messageID The ID of the message + * @param {Object} options Webhook message edit options + * @param {Object} [options.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [options.allowedMentions.everyone] Whether or not to allow @everyone/@here. + * @param {Boolean} [options.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. + * @param {Boolean | Array} [options.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. + * @param {Boolean | Array} [options.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. + * @param {Array} [options.attachments] The files to attach to the message + * @param {String} options.attachments[].id The ID of an attachment (set only when you want to update an attachment) + * @param {Buffer} options.attachments[].file A buffer containing file data (set only when uploading new files) + * @param {String} options.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [options.content] A content string + * @param {Array} [options.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {String} [options.threadID] The ID of the thread channel in the webhook's channel to edit the message in + * @returns {Promise} + */ editWebhookMessage(webhookID, token, messageID, options) { let qs = ""; if(options.threadID) { @@ -2000,15 +2002,15 @@ class Client extends EventEmitter { } /** - * Execute a slack-style webhook - * @arg {String} webhookID The ID of the webhook - * @arg {String} token The token of the webhook - * @arg {Object} options Slack webhook options - * @arg {Boolean} [options.auth=false] Whether or not to authenticate with the bot token. - * @arg {String} [options.threadID] The ID of the thread channel in the webhook's channel to send the message to - * @arg {Boolean} [options.wait=false] Whether to wait for the server to confirm the message create or not - * @returns {Promise} - */ + * Execute a slack-style webhook + * @param {String} webhookID The ID of the webhook + * @param {String} token The token of the webhook + * @param {Object} options Slack webhook options + * @param {Boolean} [options.auth=false] Whether or not to authenticate with the bot token. + * @param {String} [options.threadID] The ID of the thread channel in the webhook's channel to send the message to + * @param {Boolean} [options.wait=false] Whether to wait for the server to confirm the message create or not + * @returns {Promise} + */ executeSlackWebhook(webhookID, token, options) { const wait = !!options.wait; options.wait = undefined; @@ -2027,32 +2029,32 @@ class Client extends EventEmitter { } /** - * Execute a webhook - * @arg {String} webhookID The ID of the webhook - * @arg {String} token The token of the webhook - * @arg {Object} options Webhook execution options - * @arg {Object} [options.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [options.allowedMentions.everyone] Whether or not to allow @everyone/@here. - * @arg {Boolean | Array} [options.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. - * @arg {Boolean | Array} [options.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. - * @arg {Array} [options.appliedTags] The tags to apply to the created thread (available only in threads in thread-only channels) - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {Buffer} content.attachments[].file A buffer containing file data - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Boolean} [options.auth=false] Whether or not to authenticate with the bot token. - * @arg {String} [options.avatarURL] A URL for a custom avatar, defaults to webhook default avatar if not specified - * @arg {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [options.content] A content string - * @arg {Array} [options.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {Number} [options.flags] A number representing the flags to apply to the message. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list - * @arg {String} [options.threadID] The ID of the thread channel in the webhook's channel to send the message to - * @arg {String} [options.threadName] The name of the thread created in a forum channel - * @arg {Boolean} [options.tts=false] Whether the message should be a TTS message or not - * @arg {String} [options.username] A custom username, defaults to webhook default username if not specified - * @arg {Boolean} [options.wait=false] Whether to wait for the server to confirm the message create or not - * @returns {Promise} - */ + * Execute a webhook + * @param {String} webhookID The ID of the webhook + * @param {String} token The token of the webhook + * @param {Object} options Webhook execution options + * @param {Object} [options.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [options.allowedMentions.everyone] Whether or not to allow @everyone/@here. + * @param {Boolean | Array} [options.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. + * @param {Boolean | Array} [options.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. + * @param {Array} [options.appliedTags] The tags to apply to the created thread (available only in threads in thread-only channels) + * @param {Array} [content.attachments] The files to attach to the message + * @param {Buffer} content.attachments[].file A buffer containing file data + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Boolean} [options.auth=false] Whether or not to authenticate with the bot token. + * @param {String} [options.avatarURL] A URL for a custom avatar, defaults to webhook default avatar if not specified + * @param {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [options.content] A content string + * @param {Array} [options.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {Number} [options.flags] A number representing the flags to apply to the message. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list + * @param {String} [options.threadID] The ID of the thread channel in the webhook's channel to send the message to + * @param {String} [options.threadName] The name of the thread created in a forum channel + * @param {Boolean} [options.tts=false] Whether the message should be a TTS message or not + * @param {String} [options.username] A custom username, defaults to webhook default username if not specified + * @param {Boolean} [options.wait=false] Whether to wait for the server to confirm the message create or not + * @returns {Promise} + */ executeWebhook(webhookID, token, options) { let qs = ""; if(options.wait) { @@ -2081,9 +2083,9 @@ class Client extends EventEmitter { /** * Follow a NewsChannel in another channel. This creates a webhook in the target channel - * @arg {String} channelID The ID of the NewsChannel - * @arg {String} webhookChannelID The ID of the target channel - * @arg {String} [reason] The reason to be displayed in audit logs + * @param {String} channelID The ID of the NewsChannel + * @param {String} webhookChannelID The ID of the target channel + * @param {String} [reason] The reason to be displayed in audit logs * @returns {Object} An object containing the NewsChannel's ID and the new webhook's ID */ followChannel(channelID, webhookChannelID, reason) { @@ -2091,10 +2093,10 @@ class Client extends EventEmitter { } /** - * Get all active threads in a guild - * @arg {String} guildID The ID of the guild - * @returns {Promise} An object containing an array of `threads` and an array of `members` - */ + * Get all active threads in a guild + * @param {String} guildID The ID of the guild + * @returns {Promise} An object containing an array of `threads` and an array of `members` + */ getActiveGuildThreads(guildID) { return this.requestHandler.request("GET", Endpoints.THREADS_GUILD_ACTIVE(guildID), true).then((response) => { return { @@ -2131,14 +2133,14 @@ class Client extends EventEmitter { } /** - * Get all archived threads in a channel - * @arg {String} channelID The ID of the channel - * @arg {String} type The type of thread channel, either "public" or "private" - * @arg {Object} [options] Additional options when requesting archived threads - * @arg {Date} [options.before] List of threads to return before the timestamp - * @arg {Number} [options.limit] Maximum number of threads to return - * @returns {Promise} An object containing an array of `threads`, an array of `members` and whether the response `hasMore` threads that could be returned in a subsequent call - */ + * Get all archived threads in a channel + * @param {String} channelID The ID of the channel + * @param {String} type The type of thread channel, either "public" or "private" + * @param {Object} [options] Additional options when requesting archived threads + * @param {Date} [options.before] List of threads to return before the timestamp + * @param {Number} [options.limit] Maximum number of threads to return + * @returns {Promise} An object containing an array of `threads`, an array of `members` and whether the response `hasMore` threads that could be returned in a subsequent call + */ getArchivedThreads(channelID, type, options = {}) { return this.requestHandler.request("GET", Endpoints.THREADS_ARCHIVED(channelID, type), true, options).then((response) => { return { @@ -2151,8 +2153,8 @@ class Client extends EventEmitter { /** * Get an existing auto moderation rule - * @arg {String} guildID The ID of the guild to get the rule from - * @arg {String} ruleID The ID of the rule to get + * @param {String} guildID The ID of the guild to get the rule from + * @param {String} ruleID The ID of the rule to get * @returns {Promise} */ getAutoModerationRule(guildID, ruleID) { @@ -2161,7 +2163,7 @@ class Client extends EventEmitter { /** * Get a guild's auto moderation rules - * @arg {String} guildID The ID of the guild to get the rules of + * @param {String} guildID The ID of the guild to get the rules of * @returns {Promise} */ getAutoModerationRules(guildID) { @@ -2169,18 +2171,18 @@ class Client extends EventEmitter { } /** - * Get general and bot-specific info on connecting to the Discord gateway (e.g. connection ratelimit) - * @returns {Promise} Resolves with an object containing gateway connection info - */ + * Get general and bot-specific info on connecting to the Discord gateway (e.g. connection ratelimit) + * @returns {Promise} Resolves with an object containing gateway connection info + */ getBotGateway() { return this.requestHandler.request("GET", Endpoints.GATEWAY_BOT, true); } /** - * Get a Channel object from a channel ID - * @arg {String} channelID The ID of the channel - * @returns {CategoryChannel | PrivateChannel | TextChannel | TextVoiceChannel | NewsChannel | NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel} - */ + * Get a Channel object from a channel ID + * @param {String} channelID The ID of the channel + * @returns {CategoryChannel | PrivateChannel | TextChannel | TextVoiceChannel | NewsChannel | NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel} + */ getChannel(channelID) { if(!channelID) { throw new Error(`Invalid channel ID: ${channelID}`); @@ -2196,29 +2198,29 @@ class Client extends EventEmitter { } /** - * Get all invites in a channel - * @arg {String} channelID The ID of the channel - * @returns {Promise>} - */ + * Get all invites in a channel + * @param {String} channelID The ID of the channel + * @returns {Promise>} + */ getChannelInvites(channelID) { return this.requestHandler.request("GET", Endpoints.CHANNEL_INVITES(channelID), true).then((invites) => invites.map((invite) => new Invite(invite, this))); } /** - * Get all the webhooks in a channel - * @arg {String} channelID The ID of the channel to get webhooks for - * @returns {Promise>} Resolves with an array of webhook objects - */ + * Get all the webhooks in a channel + * @param {String} channelID The ID of the channel to get webhooks for + * @returns {Promise>} Resolves with an array of webhook objects + */ getChannelWebhooks(channelID) { return this.requestHandler.request("GET", Endpoints.CHANNEL_WEBHOOKS(channelID), true); } /** - * Get a global application command - * @arg {String} commandID The command id - * @arg {Boolean} [withLocalizations] Include [localizations](https://discord.com/developers/docs/interactions/application-commands#retrieving-localized-commands) in the response - * @returns {Promise} - */ + * Get a global application command + * @param {String} commandID The command id + * @param {Boolean} [withLocalizations] Include [localizations](https://discord.com/developers/docs/interactions/application-commands#retrieving-localized-commands) in the response + * @returns {Promise} + */ getCommand(commandID, withLocalizations) { let qs = ""; if(withLocalizations) { @@ -2228,20 +2230,20 @@ class Client extends EventEmitter { } /** - * Get the a guild's application command permissions - * @arg {String} guildID The guild ID - * @arg {String} commandID The command id - * @returns {Promise} Resolves with a guild application command permissions object. - */ + * Get the a guild's application command permissions + * @param {String} guildID The guild ID + * @param {String} commandID The command id + * @returns {Promise} Resolves with a guild application command permissions object. + */ getCommandPermissions(guildID, commandID) { return this.requestHandler.request("GET", Endpoints.COMMAND_PERMISSIONS(this.application.id, guildID, commandID), true); } /** - * Get the global application commands - * @arg {Boolean} [withLocalizations] Include [localizations](https://discord.com/developers/docs/interactions/application-commands#retrieving-localized-commands) in the response - * @returns {Promise} - */ + * Get the global application commands + * @param {Boolean} [withLocalizations] Include [localizations](https://discord.com/developers/docs/interactions/application-commands#retrieving-localized-commands) in the response + * @returns {Promise} + */ getCommands(withLocalizations) { let qs = ""; if(withLocalizations) { @@ -2251,10 +2253,10 @@ class Client extends EventEmitter { } /** - * Get a DM channel with a user, or create one if it does not exist - * @arg {String} userID The ID of the user - * @returns {Promise} - */ + * Get a DM channel with a user, or create one if it does not exist + * @param {String} userID The ID of the user + * @returns {Promise} + */ getDMChannel(userID) { if(this.privateChannelMap[userID]) { return Promise.resolve(this.privateChannels.get(this.privateChannelMap[userID])); @@ -2265,24 +2267,24 @@ class Client extends EventEmitter { } /** - * Get info on connecting to the Discord gateway - * @returns {Promise} Resolves with an object containing gateway connection info - */ + * Get info on connecting to the Discord gateway + * @returns {Promise} Resolves with an object containing gateway connection info + */ getGateway() { return this.requestHandler.request("GET", Endpoints.GATEWAY); } /** - * Get the audit log for a guild - * @arg {String} guildID The ID of the guild to get audit logs for - * @arg {Object} [options] Options for the request - * @arg {Number} [options.actionType] Filter entries by action type - * @arg {String} [options.after] Get entries after this entry ID - * @arg {String} [options.before] Get entries before this entry ID - * @arg {Number} [options.limit=50] The maximum number of entries to return - * @arg {String} [options.userID] Filter entries by the user that performed the action - * @returns {Promise<{autoModerationRules: Array, commands: Array, entries: Array, events: Array, integrations: Array, threads: Array, users: Array, webhooks: Array}>} - */ + * Get the audit log for a guild + * @param {String} guildID The ID of the guild to get audit logs for + * @param {Object} [options] Options for the request + * @param {Number} [options.actionType] Filter entries by action type + * @param {String} [options.after] Get entries after this entry ID + * @param {String} [options.before] Get entries before this entry ID + * @param {Number} [options.limit=50] The maximum number of entries to return + * @param {String} [options.userID] Filter entries by the user that performed the action + * @returns {Promise<{autoModerationRules: Array, commands: Array, entries: Array, events: Array, integrations: Array, threads: Array, users: Array, webhooks: Array}>} + */ getGuildAuditLog(guildID, options = {}) { options.limit ??= 50; // Legacy behavior if(options.actionType !== undefined) { @@ -2313,11 +2315,11 @@ class Client extends EventEmitter { } /** - * Get a ban from the ban list of a guild - * @arg {String} guildID The ID of the guild - * @arg {String} userID The ID of the banned user - * @returns {Promise} Resolves with {reason: String, user: User} - */ + * Get a ban from the ban list of a guild + * @param {String} guildID The ID of the guild + * @param {String} userID The ID of the banned user + * @returns {Promise} Resolves with {reason: String, user: User} + */ getGuildBan(guildID, userID) { return this.requestHandler.request("GET", Endpoints.GUILD_BAN(guildID, userID), true).then((ban) => { ban.user = new User(ban.user, this); @@ -2326,14 +2328,14 @@ class Client extends EventEmitter { } /** - * Get the ban list of a guild - * @arg {String} guildID The ID of the guild - * @arg {Object} [options] Options for the request - * @arg {String} [options.after] Only get users after given user ID - * @arg {String} [options.before] Only get users before given user ID - * @arg {Number} [options.limit=1000] The maximum number of users to return - * @returns {Promise>} Resolves with an array of { reason: String, user: User } - */ + * Get the ban list of a guild + * @param {String} guildID The ID of the guild + * @param {Object} [options] Options for the request + * @param {String} [options.after] Only get users after given user ID + * @param {String} [options.before] Only get users before given user ID + * @param {Number} [options.limit=1000] The maximum number of users to return + * @returns {Promise>} Resolves with an array of { reason: String, user: User } + */ async getGuildBans(guildID, options = {}) { const bans = await this.requestHandler.request("GET", Endpoints.GUILD_BANS(guildID), true, { after: options.after, @@ -2363,12 +2365,12 @@ class Client extends EventEmitter { } /** - * Get a guild application command - * @arg {String} guildID The guild ID - * @arg {String} commandID The command id - * @arg {Boolean} [withLocalizations] Include [localizations](https://discord.com/developers/docs/interactions/application-commands#retrieving-localized-commands) in the response - * @returns {Promise} Resolves with an command object. - */ + * Get a guild application command + * @param {String} guildID The guild ID + * @param {String} commandID The command id + * @param {Boolean} [withLocalizations] Include [localizations](https://discord.com/developers/docs/interactions/application-commands#retrieving-localized-commands) in the response + * @returns {Promise} Resolves with an command object. + */ getGuildCommand(guildID, commandID, withLocalizations) { let qs = ""; if(withLocalizations) { @@ -2378,20 +2380,20 @@ class Client extends EventEmitter { } /** - * Get the all of a guild's application command permissions - * @arg {String} guildID The guild ID - * @returns {Promise>} Resolves with an array of guild application command permissions objects. - */ + * Get the all of a guild's application command permissions + * @param {String} guildID The guild ID + * @returns {Promise>} Resolves with an array of guild application command permissions objects. + */ getGuildCommandPermissions(guildID) { return this.requestHandler.request("GET", Endpoints.GUILD_COMMAND_PERMISSIONS(this.application.id, guildID), true); } /** - * Get a guild's application commands - * @arg {String} guildID The guild id - * @arg {Boolean} [withLocalizations] Include [localizations](https://discord.com/developers/docs/interactions/application-commands#retrieving-localized-commands) in the response - * @returns {Promise} Resolves with an array of command objects. - */ + * Get a guild's application commands + * @param {String} guildID The guild id + * @param {Boolean} [withLocalizations] Include [localizations](https://discord.com/developers/docs/interactions/application-commands#retrieving-localized-commands) in the response + * @returns {Promise} Resolves with an array of command objects. + */ getGuildCommands(guildID, withLocalizations) { let qs = ""; if(withLocalizations) { @@ -2401,20 +2403,20 @@ class Client extends EventEmitter { } /** - * Get a list of integrations for a guild - * @arg {String} guildID The ID of the guild - * @returns {Promise>} - */ + * Get a list of integrations for a guild + * @param {String} guildID The ID of the guild + * @returns {Promise>} + */ getGuildIntegrations(guildID) { const guild = this.guilds.get(guildID); return this.requestHandler.request("GET", Endpoints.GUILD_INTEGRATIONS(guildID), true).then((integrations) => integrations.map((integration) => new GuildIntegration(integration, guild))); } /** - * Get all invites in a guild - * @arg {String} guildID The ID of the guild - * @returns {Promise>} - */ + * Get all invites in a guild + * @param {String} guildID The ID of the guild + * @returns {Promise>} + */ getGuildInvites(guildID) { return this.requestHandler.request("GET", Endpoints.GUILD_INVITES(guildID), true).then((invites) => invites.map((invite) => new Invite(invite, this))); } @@ -2429,37 +2431,37 @@ class Client extends EventEmitter { } /** - * Get a guild preview for a guild. Only available for community guilds. - * @arg {String} guildID The ID of the guild - * @returns {Promise} - */ + * Get a guild preview for a guild. Only available for community guilds. + * @param {String} guildID The ID of the guild + * @returns {Promise} + */ getGuildPreview(guildID) { return this.requestHandler.request("GET", Endpoints.GUILD_PREVIEW(guildID), true).then((data) => new GuildPreview(data, this)); } /** - * Get a guild's scheduled events - * @arg {String} guildID The ID of the guild - * @arg {Object} [options] Options for the request - * @arg {Boolean} [options.withUserCount] Whether to include the number of users subscribed to each event - * @returns {Promise>} - */ + * Get a guild's scheduled events + * @param {String} guildID The ID of the guild + * @param {Object} [options] Options for the request + * @param {Boolean} [options.withUserCount] Whether to include the number of users subscribed to each event + * @returns {Promise>} + */ getGuildScheduledEvents(guildID, options = {}) { options.with_user_count = options.withUserCount; return this.requestHandler.request("GET", Endpoints.GUILD_SCHEDULED_EVENTS(guildID), true, options).then((data) => data.map((event) => new GuildScheduledEvent(event, this))); } /** - * Get a list of users subscribed to a guild scheduled event - * @arg {String} guildID The ID of the guild - * @arg {String} eventID The ID of the event - * @arg {Object} [options] Options for the request - * @arg {String} [options.after] Get users after this user ID. If `options.before` is provided, this will be ignored. Fetching users in between `before` and `after` is not supported - * @arg {String} [options.before] Get users before this user ID - * @arg {Number} [options.limit=100] The number of users to get (max 100). Pagination will only work if one of `options.after` or `options.after` is also provided - * @arg {Boolean} [options.withMember] Include guild member data - * @returns {Promise>} - */ + * Get a list of users subscribed to a guild scheduled event + * @param {String} guildID The ID of the guild + * @param {String} eventID The ID of the event + * @param {Object} [options] Options for the request + * @param {String} [options.after] Get users after this user ID. If `options.before` is provided, this will be ignored. Fetching users in between `before` and `after` is not supported + * @param {String} [options.before] Get users before this user ID + * @param {Number} [options.limit=100] The number of users to get (max 100). Pagination will only work if one of `options.after` or `options.after` is also provided + * @param {Boolean} [options.withMember] Include guild member data + * @returns {Promise>} + */ getGuildScheduledEventUsers(guildID, eventID, options = {}) { const guild = this.guilds.get(guildID); @@ -2477,77 +2479,77 @@ class Client extends EventEmitter { } /** - * Get a guild template - * @arg {String} code The template code - * @returns {Promise} - */ + * Get a guild template + * @param {String} code The template code + * @returns {Promise} + */ getGuildTemplate(code) { return this.requestHandler.request("GET", Endpoints.GUILD_TEMPLATE(code), true).then((template) => new GuildTemplate(template, this)); } /** - * Get a guild's templates - * @arg {String} guildID The ID of the guild - * @returns {Promise>} - */ + * Get a guild's templates + * @param {String} guildID The ID of the guild + * @returns {Promise>} + */ getGuildTemplates(guildID) { return this.requestHandler.request("GET", Endpoints.GUILD_TEMPLATES(guildID), true).then((templates) => templates.map((t) => new GuildTemplate(t, this))); } /** - * Returns the vanity url of the guild - * @arg {String} guildID The ID of the guild - * @returns {Promise} - */ + * Returns the vanity url of the guild + * @param {String} guildID The ID of the guild + * @returns {Promise} + */ getGuildVanity(guildID) { return this.requestHandler.request("GET", Endpoints.GUILD_VANITY_URL(guildID), true); } /** - * Get all the webhooks in a guild - * @arg {String} guildID The ID of the guild to get webhooks for - * @returns {Promise>} Resolves with an array of webhook objects - */ + * Get all the webhooks in a guild + * @param {String} guildID The ID of the guild to get webhooks for + * @returns {Promise>} Resolves with an array of webhook objects + */ getGuildWebhooks(guildID) { return this.requestHandler.request("GET", Endpoints.GUILD_WEBHOOKS(guildID), true); } /** - * Get the welcome screen of a Community guild, shown to new members - * @arg {String} guildID The ID of the guild to get the welcome screen for - * @returns {Promise} - */ + * Get the welcome screen of a Community guild, shown to new members + * @param {String} guildID The ID of the guild to get the welcome screen for + * @returns {Promise} + */ getGuildWelcomeScreen(guildID) { return this.requestHandler.request("GET", Endpoints.GUILD_WELCOME_SCREEN(guildID), true); } /** - * Get a guild's widget object - * @arg {String} guildID The ID of the guild - * @returns {Promise} A guild widget object - */ + * Get a guild's widget object + * @param {String} guildID The ID of the guild + * @returns {Promise} A guild widget object + */ getGuildWidget(guildID) { return this.requestHandler.request("GET", Endpoints.GUILD_WIDGET(guildID), true); } /** - * Get a guild's widget settings object. Requires MANAGE_GUILD permission - * @arg {String} guildID The ID of the guild - * @returns {Promise} A guild widget setting object - */ + * Get a guild's widget settings object. Requires MANAGE_GUILD permission + * @param {String} guildID The ID of the guild + * @returns {Promise} A guild widget setting object + */ getGuildWidgetSettings(guildID) { return this.requestHandler.request("GET", Endpoints.GUILD_WIDGET_SETTINGS(guildID), true); } /** - * Get info on an invite - * @arg {String} inviteID The ID of the invite - * @arg {Object | Boolean} [options] Options for fetching the invite. - * @arg {Boolean} [options.withCounts] Whether to fetch additional invite info or not (approximate member counts, approximate presences, channel counts, etc.) - * @arg {Boolean} [options.withExpiration] Whether to fetch the expiration time or not - * @arg {String} [options.guildScheduledEventID] The guild scheduled event ID to include along with the invite - * @returns {Promise} - */ + * Get info on an invite + * @param {String} inviteID The ID of the invite + * @param {Object | Boolean} [options] Options for fetching the invite. + * @param {Boolean} [options.withCounts] Whether to fetch additional invite info or not (approximate member counts, approximate presences, channel counts, etc.) + * @param {Boolean} [options.withExpiration] Whether to fetch the expiration time or not + * @param {String} [options.guildScheduledEventID] The guild scheduled event ID to include along with the invite + * @returns {Promise} + */ getInvite(inviteID, options = {}) { options.with_counts = options.withCounts; options.with_expiration = options.withExpiration; @@ -2556,13 +2558,13 @@ class Client extends EventEmitter { } /** - * Get joined private archived threads in a channel - * @arg {String} channelID The ID of the channel - * @arg {Object} [options] Additional options when requesting archived threads - * @arg {Date} [options.before] List of threads to return before the timestamp - * @arg {Number} [options.limit] Maximum number of threads to return - * @returns {Promise} An object containing an array of `threads`, an array of `members` and whether the response `hasMore` threads that could be returned in a subsequent call - */ + * Get joined private archived threads in a channel + * @param {String} channelID The ID of the channel + * @param {Object} [options] Additional options when requesting archived threads + * @param {Date} [options.before] List of threads to return before the timestamp + * @param {Number} [options.limit] Maximum number of threads to return + * @returns {Promise} An object containing an array of `threads`, an array of `members` and whether the response `hasMore` threads that could be returned in a subsequent call + */ getJoinedPrivateArchivedThreads(channelID, options = {}) { return this.requestHandler.request("GET", Endpoints.THREADS_ARCHIVED_JOINED(channelID), true, options).then((response) => { return { @@ -2574,26 +2576,26 @@ class Client extends EventEmitter { } /** - * Get a previous message in a channel - * @arg {String} channelID The ID of the channel - * @arg {String} messageID The ID of the message - * @returns {Promise} - */ + * Get a previous message in a channel + * @param {String} channelID The ID of the channel + * @param {String} messageID The ID of the message + * @returns {Promise} + */ getMessage(channelID, messageID) { return this.requestHandler.request("GET", Endpoints.CHANNEL_MESSAGE(channelID, messageID), true).then((message) => new Message(message, this)); } /** - * Get a list of users who reacted with a specific reaction - * @arg {String} channelID The ID of the channel - * @arg {String} messageID The ID of the message - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @arg {Object} [options] Options for the request - * @arg {Number} [options.limit=100] The maximum number of users to get - * @arg {String} [options.after] Get users after this user ID - * @arg {Number} [options.type=0] The type of reaction to get - * @returns {Promise>} - */ + * Get a list of users who reacted with a specific reaction + * @param {String} channelID The ID of the channel + * @param {String} messageID The ID of the message + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @param {Object} [options] Options for the request + * @param {Number} [options.limit=100] The maximum number of users to get + * @param {String} [options.after] Get users after this user ID + * @param {Number} [options.type=0] The type of reaction to get + * @returns {Promise>} + */ getMessageReaction(channelID, messageID, reaction, options = {}) { if(reaction === decodeURI(reaction)) { reaction = encodeURIComponent(reaction); @@ -2603,15 +2605,15 @@ class Client extends EventEmitter { } /** - * Get previous messages in a channel - * @arg {String} channelID The ID of the channel - * @arg {Object} [options] Options for the request. - * @arg {String} [options.after] Get messages after this message ID - * @arg {String} [options.around] Get messages around this message ID (does not work with limit > 100) - * @arg {String} [options.before] Get messages before this message ID - * @arg {Number} [options.limit=50] The max number of messages to get - * @returns {Promise>} - */ + * Get previous messages in a channel + * @param {String} channelID The ID of the channel + * @param {Object} [options] Options for the request. + * @param {String} [options.after] Get messages after this message ID + * @param {String} [options.around] Get messages around this message ID (does not work with limit > 100) + * @param {String} [options.before] Get messages before this message ID + * @param {Number} [options.limit=50] The max number of messages to get + * @returns {Promise>} + */ async getMessages(channelID, options = {}) { options.limit ??= 50; // Legacy behavior let limit = options.limit; @@ -2657,18 +2659,18 @@ class Client extends EventEmitter { } /** - * Get data on the bot's OAuth2 application. See also `getApplication()` for more info. - * @returns {Promise} The bot's application data. Refer to [Discord's Documentation](https://discord.com/developers/docs/resources/application#application-object) for object structure - */ + * Get data on the bot's OAuth2 application. See also `getApplication()` for more info. + * @returns {Promise} The bot's application data. Refer to [Discord's Documentation](https://discord.com/developers/docs/resources/application#application-object) for object structure + */ getOAuthApplication() { return this.requestHandler.request("GET", Endpoints.OAUTH2_APPLICATION, true); } /** - * Get all the pins in a channel - * @arg {String} channelID The ID of the channel - * @returns {Promise>} - */ + * Get all the pins in a channel + * @param {String} channelID The ID of the channel + * @returns {Promise>} + */ getPins(channelID) { return this.requestHandler.request("GET", Endpoints.CHANNEL_PINS(channelID), true).then((messages) => messages.map((message) => new Message(message, this))); } @@ -2688,13 +2690,13 @@ class Client extends EventEmitter { } /** - * Get the prune count for a guild - * @arg {String} guildID The ID of the guild - * @arg {Number} [options] The options to use to get number of prune members - * @arg {Number} [options.days=7] The number of days of inactivity to prune for - * @arg {Array} [options.includeRoles] An array of role IDs that members must have to be considered for pruning - * @returns {Promise} Resolves with the number of members that would be pruned - */ + * Get the prune count for a guild + * @param {String} guildID The ID of the guild + * @param {Number} [options] The options to use to get number of prune members + * @param {Number} [options.days=7] The number of days of inactivity to prune for + * @param {Array} [options.includeRoles] An array of role IDs that members must have to be considered for pruning + * @returns {Promise} Resolves with the number of members that would be pruned + */ getPruneCount(guildID, options = {}) { return this.requestHandler.request("GET", Endpoints.GUILD_PRUNE(guildID), true, { days: options.days, @@ -2703,10 +2705,10 @@ class Client extends EventEmitter { } /** - * Get a channel's data via the REST API. REST mode is required to use this endpoint. - * @arg {String} channelID The ID of the channel - * @returns {Promise} - */ + * Get a channel's data via the REST API. REST mode is required to use this endpoint. + * @param {String} channelID The ID of the channel + * @returns {Promise} + */ getRESTChannel(channelID) { if(!this.options.restMode) { return Promise.reject(new Error("Dysnomia REST mode is not enabled")); @@ -2716,11 +2718,11 @@ class Client extends EventEmitter { } /** - * Get a guild's data via the REST API. REST mode is required to use this endpoint. - * @arg {String} guildID The ID of the guild - * @arg {Boolean} [withCounts=false] Whether the guild object will have approximateMemberCount and approximatePresenceCount - * @returns {Promise} - */ + * Get a guild's data via the REST API. REST mode is required to use this endpoint. + * @param {String} guildID The ID of the guild + * @param {Boolean} [withCounts=false] Whether the guild object will have approximateMemberCount and approximatePresenceCount + * @returns {Promise} + */ getRESTGuild(guildID, withCounts = false) { if(!this.options.restMode) { return Promise.reject(new Error("Dysnomia REST mode is not enabled")); @@ -2731,10 +2733,10 @@ class Client extends EventEmitter { } /** - * Get a guild's channels via the REST API. REST mode is required to use this endpoint. - * @arg {String} guildID The ID of the guild - * @returns {Promise>} - */ + * Get a guild's channels via the REST API. REST mode is required to use this endpoint. + * @param {String} guildID The ID of the guild + * @returns {Promise>} + */ getRESTGuildChannels(guildID) { if(!this.options.restMode) { return Promise.reject(new Error("Dysnomia REST mode is not enabled")); @@ -2744,11 +2746,11 @@ class Client extends EventEmitter { } /** - * Get a guild emoji via the REST API. REST mode is required to use this endpoint. - * @arg {String} guildID The ID of the guild - * @arg {String} emojiID The ID of the emoji - * @returns {Promise} An emoji object - */ + * Get a guild emoji via the REST API. REST mode is required to use this endpoint. + * @param {String} guildID The ID of the guild + * @param {String} emojiID The ID of the emoji + * @returns {Promise} An emoji object + */ getRESTGuildEmoji(guildID, emojiID) { if(!this.options.restMode) { return Promise.reject(new Error("Dysnomia REST mode is not enabled")); @@ -2757,10 +2759,10 @@ class Client extends EventEmitter { } /** - * Get a guild's emojis via the REST API. REST mode is required to use this endpoint. - * @arg {String} guildID The ID of the guild - * @returns {Promise>} An array of guild emoji objects - */ + * Get a guild's emojis via the REST API. REST mode is required to use this endpoint. + * @param {String} guildID The ID of the guild + * @returns {Promise>} An array of guild emoji objects + */ getRESTGuildEmojis(guildID) { if(!this.options.restMode) { return Promise.reject(new Error("Dysnomia REST mode is not enabled")); @@ -2769,11 +2771,11 @@ class Client extends EventEmitter { } /** - * Get a guild's members via the REST API. REST mode is required to use this endpoint. - * @arg {String} guildID The ID of the guild - * @arg {String} memberID The ID of the member - * @returns {Promise} - */ + * Get a guild's members via the REST API. REST mode is required to use this endpoint. + * @param {String} guildID The ID of the guild + * @param {String} memberID The ID of the member + * @returns {Promise} + */ getRESTGuildMember(guildID, memberID) { if(!this.options.restMode) { return Promise.reject(new Error("Dysnomia REST mode is not enabled")); @@ -2782,13 +2784,13 @@ class Client extends EventEmitter { } /** - * Get a guild's members via the REST API. REST mode is required to use this endpoint. - * @arg {String} guildID The ID of the guild - * @arg {Object} [options] Options for the request. - * @arg {String} [options.after] The highest user ID of the previous page - * @arg {Number} [options.limit=1] The max number of members to get (1 to 1000) - * @returns {Promise>} - */ + * Get a guild's members via the REST API. REST mode is required to use this endpoint. + * @param {String} guildID The ID of the guild + * @param {Object} [options] Options for the request. + * @param {String} [options.after] The highest user ID of the previous page + * @param {Number} [options.limit=1] The max number of members to get (1 to 1000) + * @returns {Promise>} + */ getRESTGuildMembers(guildID, options = {}) { if(!this.options.restMode) { return Promise.reject(new Error("Dysnomia REST mode is not enabled")); @@ -2797,10 +2799,10 @@ class Client extends EventEmitter { } /** - * Get a guild's roles via the REST API. REST mode is required to use this endpoint. - * @arg {String} guildID The ID of the guild - * @returns {Promise>} - */ + * Get a guild's roles via the REST API. REST mode is required to use this endpoint. + * @param {String} guildID The ID of the guild + * @returns {Promise>} + */ getRESTGuildRoles(guildID) { if(!this.options.restMode) { return Promise.reject(new Error("Dysnomia REST mode is not enabled")); @@ -2809,14 +2811,14 @@ class Client extends EventEmitter { } /** - * Get a list of the user's guilds via the REST API. REST mode is required to use this endpoint. - * @arg {Object} [options] Options for the request. - * @arg {String} [options.after] The highest guild ID of the previous page - * @arg {String} [options.before] The lowest guild ID of the next page - * @arg {Number} [options.limit=200] The max number of guilds to get (1 to 200) - * @arg {Boolean} [options.withCounts] Whether the guild objects will have approximateMemberCount and approximatePresenceCount - * @returns {Promise>} - */ + * Get a list of the user's guilds via the REST API. REST mode is required to use this endpoint. + * @param {Object} [options] Options for the request. + * @param {String} [options.after] The highest guild ID of the previous page + * @param {String} [options.before] The lowest guild ID of the next page + * @param {Number} [options.limit=200] The max number of guilds to get (1 to 200) + * @param {Boolean} [options.withCounts] Whether the guild objects will have approximateMemberCount and approximatePresenceCount + * @returns {Promise>} + */ getRESTGuilds(options = {}) { // TODO type if(!this.options.restMode) { @@ -2827,13 +2829,13 @@ class Client extends EventEmitter { } /** - * Get a guild scheduled event via the REST API. REST mode is required to use this endpoint. - * @arg {String} guildID The ID of the guild - * @arg {String} eventID The ID of the guild scheduled event - * @arg {Object} [options] Options for the request - * @arg {Boolean} [options.withUserCount] Whether to include the number of users subscribed to the event - * @returns {Promise} - */ + * Get a guild scheduled event via the REST API. REST mode is required to use this endpoint. + * @param {String} guildID The ID of the guild + * @param {String} eventID The ID of the guild scheduled event + * @param {Object} [options] Options for the request + * @param {Boolean} [options.withUserCount] Whether to include the number of users subscribed to the event + * @returns {Promise} + */ getRESTGuildScheduledEvent(guildID, eventID, options = {}) { if(!this.options.restMode) { return Promise.reject(new Error("Dysnomia REST mode is not enabled")); @@ -2844,11 +2846,11 @@ class Client extends EventEmitter { } /** - * Get a guild sticker via the REST API. REST mode is required to use this endpoint. - * @arg {String} guildID The ID of the guild - * @arg {String} stickerID The ID of the sticker - * @returns {Promise} A sticker object - */ + * Get a guild sticker via the REST API. REST mode is required to use this endpoint. + * @param {String} guildID The ID of the guild + * @param {String} stickerID The ID of the sticker + * @returns {Promise} A sticker object + */ getRESTGuildSticker(guildID, stickerID) { if(!this.options.restMode) { return Promise.reject(new Error("Dysnomia REST mode is not enabled")); @@ -2857,10 +2859,10 @@ class Client extends EventEmitter { } /** - * Get a guild's stickers via the REST API. REST mode is required to use this endpoint. - * @arg {String} guildID The ID of the guild - * @returns {Promise>} An array of guild sticker objects - */ + * Get a guild's stickers via the REST API. REST mode is required to use this endpoint. + * @param {String} guildID The ID of the guild + * @returns {Promise>} An array of guild sticker objects + */ getRESTGuildStickers(guildID) { if(!this.options.restMode) { return Promise.reject(new Error("Dysnomia REST mode is not enabled")); @@ -2869,9 +2871,9 @@ class Client extends EventEmitter { } /** - * Get a sticker via the REST API. REST mode is required to use this endpoint. - * @arg {String} stickerID The ID of the sticker - * @returns {Promise} A sticker object + * Get a sticker via the REST API. REST mode is required to use this endpoint. + * @param {String} stickerID The ID of the sticker + * @returns {Promise} A sticker object */ getRESTSticker(stickerID) { if(!this.options.restMode) { @@ -2881,10 +2883,10 @@ class Client extends EventEmitter { } /** - * Get a user's data via the REST API. REST mode is required to use this endpoint. - * @arg {String} userID The ID of the user - * @returns {Promise} - */ + * Get a user's data via the REST API. REST mode is required to use this endpoint. + * @param {String} userID The ID of the user + * @returns {Promise} + */ getRESTUser(userID) { if(!this.options.restMode) { return Promise.reject(new Error("Dysnomia REST mode is not enabled")); @@ -2905,18 +2907,18 @@ class Client extends EventEmitter { } /** - * Get properties of the bot user - * @returns {Promise} - */ + * Get properties of the bot user + * @returns {Promise} + */ getSelf() { return this.requestHandler.request("GET", Endpoints.USER("@me"), true).then((data) => new ExtendedUser(data, this)); } /** - * Get the stage instance associated with a stage channel - * @arg {String} channelID The stage channel ID - * @returns {Promise} - */ + * Get the stage instance associated with a stage channel + * @param {String} channelID The stage channel ID + * @returns {Promise} + */ getStageInstance(channelID) { return this.requestHandler.request("GET", Endpoints.STAGE_INSTANCE(channelID), true).then((instance) => new StageInstance(instance, this)); } @@ -2931,10 +2933,10 @@ class Client extends EventEmitter { /** * Gets a thread member object for a specified user - * @arg {String} channelID The ID of the thread channel - * @arg {String} memberID The ID of the member - * @arg {Object} [options] Options for the request - * @arg {Boolean} [options.withMember] Whether to include a Member object for each thread member + * @param {String} channelID The ID of the thread channel + * @param {String} memberID The ID of the member + * @param {Object} [options] Options for the request + * @param {Boolean} [options.withMember] Whether to include a Member object for each thread member * @returns {Promise} */ getThreadMember(channelID, memberID, options = {}) { @@ -2943,69 +2945,69 @@ class Client extends EventEmitter { } /** - * Get a list of members that are part of a thread channel - * @arg {String} channelID The ID of the thread channel - * @arg {Object} [options] Options for the request - * @arg {String} [options.after] Fetch thread members after this user ID - * @arg {Number} [options.limit] The maximum amount of thread members to fetch - * @arg {Boolean} [options.withMember] Whether to include a Member object for each thread member - * @returns {Promise>} - */ + * Get a list of members that are part of a thread channel + * @param {String} channelID The ID of the thread channel + * @param {Object} [options] Options for the request + * @param {String} [options.after] Fetch thread members after this user ID + * @param {Number} [options.limit] The maximum amount of thread members to fetch + * @param {Boolean} [options.withMember] Whether to include a Member object for each thread member + * @returns {Promise>} + */ getThreadMembers(channelID, options = {}) { options.with_member = options.withMember; return this.requestHandler.request("GET", Endpoints.THREAD_MEMBERS(channelID), true, options).then((members) => members.map((member) => new ThreadMember(member, this))); } /** - * Get a list of general/guild-specific voice regions - * @arg {String} [guildID] The ID of the guild - * @returns {Promise>} Resolves with an array of voice region objects - */ + * Get a list of general/guild-specific voice regions + * @param {String} [guildID] The ID of the guild + * @returns {Promise>} Resolves with an array of voice region objects + */ getVoiceRegions(guildID) { return guildID ? this.requestHandler.request("GET", Endpoints.GUILD_VOICE_REGIONS(guildID), true) : this.requestHandler.request("GET", Endpoints.VOICE_REGIONS, true); } /** - * Get a webhook - * @arg {String} webhookID The ID of the webhook - * @arg {String} [token] The token of the webhook, used instead of the Bot Authorization token - * @returns {Promise} Resolves with a webhook object - */ + * Get a webhook + * @param {String} webhookID The ID of the webhook + * @param {String} [token] The token of the webhook, used instead of the Bot Authorization token + * @returns {Promise} Resolves with a webhook object + */ getWebhook(webhookID, token) { return this.requestHandler.request("GET", token ? Endpoints.WEBHOOK_TOKEN(webhookID, token) : Endpoints.WEBHOOK(webhookID), !token); } /** - * Get a webhook message - * @arg {String} webhookID The ID of the webhook - * @arg {String} token The token of the webhook - * @arg {String} messageID The message ID of a message sent by this webhook - * @returns {Promise} Resolves with a webhook message - */ + * Get a webhook message + * @param {String} webhookID The ID of the webhook + * @param {String} token The token of the webhook + * @param {String} messageID The message ID of a message sent by this webhook + * @returns {Promise} Resolves with a webhook message + */ getWebhookMessage(webhookID, token, messageID) { return this.requestHandler.request("GET", Endpoints.WEBHOOK_MESSAGE(webhookID, token, messageID)).then((message) => new Message(message, this)); } /** - * Join a thread - * @arg {String} channelID The ID of the thread channel - * @arg {String} [userID="@me"] The user ID of the user joining - * @returns {Promise} - */ + * Join a thread + * @param {String} channelID The ID of the thread channel + * @param {String} [userID="@me"] The user ID of the user joining + * @returns {Promise} + */ joinThread(channelID, userID = "@me") { return this.requestHandler.request("PUT", Endpoints.THREAD_MEMBER(channelID, userID), true); } /** - * Join a voice channel - * @arg {String} channelID The ID of the voice channel - * @arg {Object} [options] VoiceConnection constructor options - * @arg {Object} [options.opusOnly] Skip opus encoder initialization. You should not enable this unless you know what you are doing - * @arg {Object} [options.shared] Whether the VoiceConnection will be part of a SharedStream or not - * @arg {Boolean} [options.selfMute] Whether the bot joins the channel muted or not - * @arg {Boolean} [options.selfDeaf] Whether the bot joins the channel deafened or not - * @returns {Promise} Resolves with a VoiceConnection - */ + * Join a voice channel + * @param {String} channelID The ID of the voice channel + * @param {Object} [options] VoiceConnection constructor options + * @param {Object} [options.opusOnly] Skip opus encoder initialization. You should not enable this unless you know what you are doing + * @param {Object} [options.shared] Whether the VoiceConnection will be part of a SharedStream or not + * @param {Boolean} [options.selfMute] Whether the bot joins the channel muted or not + * @param {Boolean} [options.selfDeaf] Whether the bot joins the channel deafened or not + * @returns {Promise} Resolves with a VoiceConnection + */ joinVoiceChannel(channelID, options = {}) { const channel = this.getChannel(channelID); if(!channel) { @@ -3025,12 +3027,12 @@ class Client extends EventEmitter { } /** - * Kick a user from a guild - * @arg {String} guildID The ID of the guild - * @arg {String} userID The ID of the user - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Kick a user from a guild + * @param {String} guildID The ID of the guild + * @param {String} userID The ID of the user + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ kickGuildMember(guildID, userID, reason) { return this.requestHandler.request("DELETE", Endpoints.GUILD_MEMBER(guildID, userID), true, { reason @@ -3038,28 +3040,28 @@ class Client extends EventEmitter { } /** - * Leave a guild - * @arg {String} guildID The ID of the guild - * @returns {Promise} - */ + * Leave a guild + * @param {String} guildID The ID of the guild + * @returns {Promise} + */ leaveGuild(guildID) { return this.requestHandler.request("DELETE", Endpoints.USER_GUILD("@me", guildID), true); } /** - * Leave a thread - * @arg {String} channelID The ID of the thread channel - * @arg {String} [userID="@me"] The user ID of the user leaving - * @returns {Promise} - */ + * Leave a thread + * @param {String} channelID The ID of the thread channel + * @param {String} [userID="@me"] The user ID of the user leaving + * @returns {Promise} + */ leaveThread(channelID, userID = "@me") { return this.requestHandler.request("DELETE", Endpoints.THREAD_MEMBER(channelID, userID), true); } /** - * Leaves a voice channel - * @arg {String} channelID The ID of the voice channel - */ + * Leaves a voice channel + * @param {String} channelID The ID of the voice channel + */ leaveVoiceChannel(channelID) { if(!channelID || !this.channelGuildMap[channelID]) { return; @@ -3068,25 +3070,25 @@ class Client extends EventEmitter { } /** - * Pin a message - * @arg {String} channelID The ID of the channel - * @arg {String} messageID The ID of the message - * @returns {Promise} - */ + * Pin a message + * @param {String} channelID The ID of the channel + * @param {String} messageID The ID of the message + * @returns {Promise} + */ pinMessage(channelID, messageID) { return this.requestHandler.request("PUT", Endpoints.CHANNEL_PIN(channelID, messageID), true); } /** - * Begin pruning a guild - * @arg {String} guildID The ID of the guild - * @arg {Number} [options] The options to pass to prune members - * @arg {Boolean} [options.computePruneCount=true] Whether or not the number of pruned members should be returned. Discord discourages setting this to true for larger guilds - * @arg {Number} [options.days=7] The number of days of inactivity to prune for - * @arg {Array} [options.includeRoles] An array of role IDs that members must have to be considered for pruning - * @arg {String} [options.reason] The reason to be displayed in audit logs - * @returns {Promise} If computePruneCount was true, resolves with the number of pruned members - */ + * Begin pruning a guild + * @param {String} guildID The ID of the guild + * @param {Number} [options] The options to pass to prune members + * @param {Boolean} [options.computePruneCount=true] Whether or not the number of pruned members should be returned. Discord discourages setting this to true for larger guilds + * @param {Number} [options.days=7] The number of days of inactivity to prune for + * @param {Array} [options.includeRoles] An array of role IDs that members must have to be considered for pruning + * @param {String} [options.reason] The reason to be displayed in audit logs + * @returns {Promise} If computePruneCount was true, resolves with the number of pruned members + */ pruneMembers(guildID, options = {}) { return this.requestHandler.request("POST", Endpoints.GUILD_PRUNE(guildID), true, { days: options.days, @@ -3097,16 +3099,16 @@ class Client extends EventEmitter { } /** - * Purge previous messages in a channel with an optional filter (bot accounts only) - * @arg {String} channelID The ID of the channel - * @arg {Object} options Options for the request. - * @arg {String} [options.after] Get messages after this message ID - * @arg {String} [options.before] Get messages before this message ID - * @arg {Function} [options.filter] Optional filter function that returns a boolean when passed a Message object - * @arg {Number} options.limit The max number of messages to search through, -1 for no limit - * @arg {String} [options.reason] The reason to be displayed in audit logs - * @returns {Promise} Resolves with the number of messages deleted - */ + * Purge previous messages in a channel with an optional filter (bot accounts only) + * @param {String} channelID The ID of the channel + * @param {Object} options Options for the request. + * @param {String} [options.after] Get messages after this message ID + * @param {String} [options.before] Get messages before this message ID + * @param {Function} [options.filter] Optional filter function that returns a boolean when passed a Message object + * @param {Number} options.limit The max number of messages to search through, -1 for no limit + * @param {String} [options.reason] The reason to be displayed in audit logs + * @returns {Promise} Resolves with the number of messages deleted + */ async purgeChannel(channelID, options) { if(typeof options.filter === "string") { const filter = options.filter; @@ -3175,13 +3177,13 @@ class Client extends EventEmitter { } /** - * Remove a role from a guild member - * @arg {String} guildID The ID of the guild - * @arg {String} memberID The ID of the member - * @arg {String} roleID The ID of the role - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Remove a role from a guild member + * @param {String} guildID The ID of the guild + * @param {String} memberID The ID of the member + * @param {String} roleID The ID of the role + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ removeGuildMemberRole(guildID, memberID, roleID, reason) { return this.requestHandler.request("DELETE", Endpoints.GUILD_MEMBER_ROLE(guildID, memberID, roleID), true, { reason @@ -3189,13 +3191,13 @@ class Client extends EventEmitter { } /** - * Remove a reaction from a message - * @arg {String} channelID The ID of the channel - * @arg {String} messageID The ID of the message - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @arg {String} [userID="@me"] The ID of the user to remove the reaction for - * @returns {Promise} - */ + * Remove a reaction from a message + * @param {String} channelID The ID of the channel + * @param {String} messageID The ID of the message + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @param {String} [userID="@me"] The ID of the user to remove the reaction for + * @returns {Promise} + */ removeMessageReaction(channelID, messageID, reaction, userID) { if(reaction === decodeURI(reaction)) { reaction = encodeURIComponent(reaction); @@ -3204,12 +3206,12 @@ class Client extends EventEmitter { } /** - * Remove all reactions from a message for a single emoji. - * @arg {String} channelID The ID of the channel - * @arg {String} messageID The ID of the message - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @returns {Promise} - */ + * Remove all reactions from a message for a single emoji. + * @param {String} channelID The ID of the channel + * @param {String} messageID The ID of the message + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @returns {Promise} + */ removeMessageReactionEmoji(channelID, messageID, reaction) { if(reaction === decodeURI(reaction)) { reaction = encodeURIComponent(reaction); @@ -3218,22 +3220,22 @@ class Client extends EventEmitter { } /** - * Remove all reactions from a message - * @arg {String} channelID The ID of the channel - * @arg {String} messageID The ID of the message - * @returns {Promise} - */ + * Remove all reactions from a message + * @param {String} channelID The ID of the channel + * @param {String} messageID The ID of the message + * @returns {Promise} + */ removeMessageReactions(channelID, messageID) { return this.requestHandler.request("DELETE", Endpoints.CHANNEL_MESSAGE_REACTIONS(channelID, messageID), true); } /** - * Search for guild members by partial nickname/username - * @arg {String} guildID The ID of the guild - * @arg {String} query The query string to match username(s) and nickname(s) against - * @arg {Number} [limit=1] The maximum number of members you want returned, capped at 100 - * @returns {Promise>} - */ + * Search for guild members by partial nickname/username + * @param {String} guildID The ID of the guild + * @param {String} query The query string to match username(s) and nickname(s) against + * @param {Number} [limit=1] The maximum number of members you want returned, capped at 100 + * @returns {Promise>} + */ searchGuildMembers(guildID, query, limit) { return this.requestHandler.request("GET", Endpoints.GUILD_MEMBERS_SEARCH(guildID), true, { query, @@ -3245,31 +3247,31 @@ class Client extends EventEmitter { } /** - * Send typing status in a channel - * @arg {String} channelID The ID of the channel - * @returns {Promise} - */ + * Send typing status in a channel + * @param {String} channelID The ID of the channel + * @returns {Promise} + */ sendChannelTyping(channelID) { return this.requestHandler.request("POST", Endpoints.CHANNEL_TYPING(channelID), true); } /** - * Force a guild template to sync - * @arg {String} guildID The ID of the guild - * @arg {String} code The template code - * @returns {Promise} - */ + * Force a guild template to sync + * @param {String} guildID The ID of the guild + * @param {String} code The template code + * @returns {Promise} + */ syncGuildTemplate(guildID, code) { return this.requestHandler.request("PUT", Endpoints.GUILD_TEMPLATE_GUILD(guildID, code), true).then((template) => new GuildTemplate(template, this)); } /** - * Unban a user from a guild - * @arg {String} guildID The ID of the guild - * @arg {String} userID The ID of the user - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Unban a user from a guild + * @param {String} guildID The ID of the guild + * @param {String} userID The ID of the user + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ unbanGuildMember(guildID, userID, reason) { return this.requestHandler.request("DELETE", Endpoints.GUILD_BAN(guildID, userID), true, { reason @@ -3277,11 +3279,11 @@ class Client extends EventEmitter { } /** - * Unpin a message - * @arg {String} channelID The ID of the channel - * @arg {String} messageID The ID of the message - * @returns {Promise} - */ + * Unpin a message + * @param {String} channelID The ID of the channel + * @param {String} messageID The ID of the message + * @returns {Promise} + */ unpinMessage(channelID, messageID) { return this.requestHandler.request("DELETE", Endpoints.CHANNEL_PIN(channelID, messageID), true); } diff --git a/lib/Constants.js b/lib/Constants.js index f87871a2..b030bc98 100644 --- a/lib/Constants.js +++ b/lib/Constants.js @@ -1,5 +1,7 @@ "use strict"; +/* eslint @stylistic/key-spacing: ["error", {align: "value"}] */ + module.exports.GATEWAY_VERSION = 10; module.exports.REST_VERSION = 10; @@ -130,11 +132,11 @@ module.exports.AuditLogActions = { APPLICATION_COMMAND_PERMISSION_UPDATE: 121, - AUTO_MODERATION_RULE_CREATE: 140, - AUTO_MODERATION_RULE_UPDATE: 141, - AUTO_MODERATION_RULE_DELETE: 142, - AUTO_MODERATION_BLOCK_MESSAGE: 143, - AUTO_MODERATION_FLAG_TO_CHANNEL: 144, + AUTO_MODERATION_RULE_CREATE: 140, + AUTO_MODERATION_RULE_UPDATE: 141, + AUTO_MODERATION_RULE_DELETE: 142, + AUTO_MODERATION_BLOCK_MESSAGE: 143, + AUTO_MODERATION_FLAG_TO_CHANNEL: 144, AUTO_MODERATION_USER_COMMUNICATION_DISABLED: 145, CREATOR_MONETIZATION_REQUEST_CREATED: 150, @@ -196,20 +198,20 @@ module.exports.ChannelFlags = { }; module.exports.ChannelTypes = { - GUILD_TEXT: 0, - DM: 1, - GUILD_VOICE: 2, - GROUP_DM: 3, - GUILD_CATEGORY: 4, - GUILD_ANNOUNCEMENT: 5, - - ANNOUNCEMENT_THREAD: 10, - PUBLIC_THREAD: 11, - PRIVATE_THREAD: 12, - GUILD_STAGE_VOICE: 13, - GUILD_DIRECTORY: 14, - GUILD_FORUM: 15, - GUILD_MEDIA: 16 + GUILD_TEXT: 0, + DM: 1, + GUILD_VOICE: 2, + GROUP_DM: 3, + GUILD_CATEGORY: 4, + GUILD_ANNOUNCEMENT: 5, + // (undocumented types) + ANNOUNCEMENT_THREAD: 10, + PUBLIC_THREAD: 11, + PRIVATE_THREAD: 12, + GUILD_STAGE_VOICE: 13, + GUILD_DIRECTORY: 14, + GUILD_FORUM: 15, + GUILD_MEDIA: 16 }; module.exports.ComponentTypes = { @@ -345,7 +347,8 @@ const Intents = { directMessagePolls: 1 << 25 }; -Intents.allNonPrivileged = Intents.guilds +Intents.allNonPrivileged + = Intents.guilds | Intents.guildModeration | Intents.guildEmojisAndStickers | Intents.guildIntegrations @@ -363,7 +366,8 @@ Intents.allNonPrivileged = Intents.guilds | Intents.autoModerationExecution | Intents.guildMessagePolls | Intents.directMessagePolls; -Intents.allPrivileged = Intents.guildMembers +Intents.allPrivileged + = Intents.guildMembers | Intents.guildPresences | Intents.messageContent; Intents.all = Intents.allNonPrivileged | Intents.allPrivileged; @@ -404,10 +408,10 @@ module.exports.MFALevels = { }; module.exports.MemberFlags = { - DID_REJOIN: 1 << 0, - COMPLETED_ONBOARDING: 1 << 1, - BYPASSES_VERIFICATION: 1 << 2, - STARTED_ONBOARDING: 1 << 3 + DID_REJOIN: 1 << 0, + COMPLETED_ONBOARDING: 1 << 1, + BYPASSES_VERIFICATION: 1 << 2, + STARTED_ONBOARDING: 1 << 3 }; module.exports.MessageActivityTypes = { @@ -521,7 +525,7 @@ const Permissions = { manageNicknames: 1n << 27n, manageRoles: 1n << 28n, manageWebhooks: 1n << 29n, - manageGuildExpressions: 1n << 30n, manageEmojisAndStickers: 1n << 30n, // [DEPRECATED] + manageGuildExpressions: 1n << 30n, manageEmojisAndStickers: 1n << 30n, // [DEPRECATED] useApplicationCommands: 1n << 31n, voiceRequestToSpeak: 1n << 32n, manageEvents: 1n << 33n, @@ -541,7 +545,8 @@ const Permissions = { sendPolls: 1n << 49n, useExternalApps: 1n << 50n }; -Permissions.allGuild = Permissions.kickMembers +Permissions.allGuild + = Permissions.kickMembers | Permissions.banMembers | Permissions.administrator | Permissions.manageChannels @@ -558,7 +563,8 @@ Permissions.allGuild = Permissions.kickMembers | Permissions.viewCreatorMonetizationAnalytics | Permissions.createGuildExpressions | Permissions.createEvents; -Permissions.allText = Permissions.createInstantInvite +Permissions.allText + = Permissions.createInstantInvite | Permissions.manageChannels | Permissions.addReactions | Permissions.viewChannel @@ -581,7 +587,8 @@ Permissions.allText = Permissions.createInstantInvite | Permissions.sendVoiceMessages | Permissions.sendPolls | Permissions.useExternalApps; -Permissions.allVoice = Permissions.createInstantInvite +Permissions.allVoice + = Permissions.createInstantInvite | Permissions.manageChannels | Permissions.voicePrioritySpeaker | Permissions.voiceStream @@ -719,24 +726,24 @@ module.exports.TextInputStyles = { }; module.exports.UserFlags = { - NONE: 0, - STAFF: 1 << 0, - PARTNER: 1 << 1, - HYPESQUAD: 1 << 2, - BUG_HUNTER_LEVEL_1: 1 << 3, - HHYPESQUAD_ONLINE_HOUSE_1: 1 << 6, - HYPESQUAD_ONLINE_HOUSE_2: 1 << 7, - HYPESQUAD_ONLINE_HOUSE_3: 1 << 8, - PREMIUM_EARLY_SUPPORTER: 1 << 9, - TEAM_PSEUDO_USER: 1 << 10, - SYSTEM: 1 << 12, - BUG_HUNTER_LEVEL_2: 1 << 14, - VERIFIED_BOT: 1 << 16, - VERIFIED_DEVELOPER: 1 << 17, - CERTIFIED_MODERATOR: 1 << 18, - BOT_HTTP_INTERACTIONS: 1 << 19, - SPAMMER: 1 << 20, - ACTIVE_DEVELOPER: 1 << 22 + NONE: 0, + STAFF: 1 << 0, + PARTNER: 1 << 1, + HYPESQUAD: 1 << 2, + BUG_HUNTER_LEVEL_1: 1 << 3, + HHYPESQUAD_ONLINE_HOUSE_1: 1 << 6, + HYPESQUAD_ONLINE_HOUSE_2: 1 << 7, + HYPESQUAD_ONLINE_HOUSE_3: 1 << 8, + PREMIUM_EARLY_SUPPORTER: 1 << 9, + TEAM_PSEUDO_USER: 1 << 10, + SYSTEM: 1 << 12, + BUG_HUNTER_LEVEL_2: 1 << 14, + VERIFIED_BOT: 1 << 16, + VERIFIED_DEVELOPER: 1 << 17, + CERTIFIED_MODERATOR: 1 << 18, + BOT_HTTP_INTERACTIONS: 1 << 19, + SPAMMER: 1 << 20, + ACTIVE_DEVELOPER: 1 << 22 }; module.exports.VerificationLevels = { diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index a9be6e35..0db97386 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -45,9 +45,9 @@ try { } /** -* Represents a shard -* @extends EventEmitter -*/ + * Represents a shard + * @extends EventEmitter + */ class Shard extends EventEmitter { #onWSClose; #onWSError; @@ -87,17 +87,17 @@ class Shard extends EventEmitter { */ this.ready = true; /** - * Fired when the shard turns ready - * @event Shard#ready - */ + * Fired when the shard turns ready + * @event Shard#ready + */ super.emit("ready"); } } } /** - * Tells the shard to connect - */ + * Tells the shard to connect + */ connect() { if(this.ws && this.ws.readyState != WebSocket.CLOSED) { this.emit("error", new Error("Existing connection detected"), this.id); @@ -126,11 +126,11 @@ class Shard extends EventEmitter { } /** - * Disconnects the shard - * @arg {Object?} [options] Shard disconnect options - * @arg {String | Boolean} [options.reconnect] false means destroy everything, true means you want to reconnect in the future, "auto" will autoreconnect - * @arg {Error} [error] The error that causes the disconnect - */ + * Disconnects the shard + * @param {Object?} [options] Shard disconnect options + * @param {String | Boolean} [options.reconnect] false means destroy everything, true means you want to reconnect in the future, "auto" will autoreconnect + * @param {Error} [error] The error that causes the disconnect + */ disconnect(options = {}, error) { if(!this.ws) { return; @@ -167,10 +167,10 @@ class Shard extends EventEmitter { } /** - * Fired when the shard disconnects - * @event Shard#disconnect - * @prop {Error?} err The error, if any - */ + * Fired when the shard disconnects + * @event Shard#disconnect + * @prop {Error?} err The error, if any + */ super.emit("disconnect", error); if(this.sessionID && this.connectAttempts >= this.client.shards.options.maxResumeAttempts) { @@ -181,11 +181,11 @@ class Shard extends EventEmitter { if(options.reconnect === "auto" && this.client.shards.options.autoreconnect) { /** - * Fired when stuff happens and gives more info - * @event Client#debug - * @prop {String} message The debug message - * @prop {Number} id The ID of the shard - */ + * Fired when stuff happens and gives more info + * @event Client#debug + * @prop {String} message The debug message + * @prop {Number} id The ID of the shard + */ if(this.sessionID) { this.emit("debug", `Immediately reconnecting for potential resume | Attempt ${this.connectAttempts}`, this.id); this.client.shards.connect(this); @@ -202,9 +202,9 @@ class Shard extends EventEmitter { } /** - * Update the bot's AFK status. - * @arg {Boolean} afk Whether the bot user is AFK or not - */ + * Update the bot's AFK status. + * @param {Boolean} afk Whether the bot user is AFK or not + */ editAFK(afk) { this.presence.afk = !!afk; @@ -212,14 +212,14 @@ class Shard extends EventEmitter { } /** - * Updates the bot's status on all guilds the shard is in - * @arg {String} [status] Sets the bot's status, either "online", "idle", "dnd", or "invisible" - * @arg {Array | Object} [activities] Sets the bot's activities. A single activity object is also accepted for backwards compatibility - * @arg {String} activities[].name The name of the activity - * @arg {Number} activities[].type The type of the activity. 0 is playing, 1 is streaming (Twitch only), 2 is listening, 3 is watching, 4 is custom status, 5 is competing in - * @arg {String} [activities[].url] The URL of the activity - * @arg {String} [activities[].state] The state of the activity - if using a custom status, this is the text to be shown to the users - */ + * Updates the bot's status on all guilds the shard is in + * @param {String} [status] Sets the bot's status, either "online", "idle", "dnd", or "invisible" + * @param {Array | Object} [activities] Sets the bot's activities. A single activity object is also accepted for backwards compatibility + * @param {String} activities[].name The name of the activity + * @param {Number} activities[].type The type of the activity. 0 is playing, 1 is streaming (Twitch only), 2 is listening, 3 is watching, 4 is custom status, 5 is competing in + * @param {String} [activities[].url] The URL of the activity + * @param {String} [activities[].state] The state of the activity - if using a custom status, this is the text to be shown to the users + */ editStatus(status, activities) { if(activities === undefined && typeof status === "object") { activities = status; @@ -297,11 +297,11 @@ class Shard extends EventEmitter { identify() { if(this.client.shards.options.compress && !ZlibSync) { /** - * Fired when the shard encounters an error - * @event Client#error - * @prop {Error} err The error - * @prop {Number} id The ID of the shard - */ + * Fired when the shard encounters an error + * @event Client#error + * @prop {Error} err The error + * @prop {Number} id The ID of the shard + */ this.emit("error", new Error("pako/zlib-sync not found, cannot decompress data")); return; } @@ -317,9 +317,9 @@ class Shard extends EventEmitter { large_threshold: this.client.shards.options.largeThreshold, intents: this.client.shards.options.intents, properties: { - "os": process.platform, - "browser": "Dysnomia", - "device": "Dysnomia" + os: process.platform, + browser: "Dysnomia", + device: "Dysnomia" } }; if(this.client.shards.options.maxShards > 1) { @@ -368,22 +368,22 @@ class Shard extends EventEmitter { onPacket(packet) { if(this.listeners("rawWS").length > 0 || this.client.listeners("rawWS").length) { /** - * Fired when the shard receives a websocket packet - * @event Client#rawWS - * @prop {Object} packet The packet - * @prop {Number} id The ID of the shard - */ + * Fired when the shard receives a websocket packet + * @event Client#rawWS + * @prop {Object} packet The packet + * @prop {Number} id The ID of the shard + */ this.emit("rawWS", packet, this.id); } if(packet.s) { if(packet.s > this.seq + 1 && this.ws && this.status !== "resuming") { /** - * Fired to warn of something weird but non-breaking happening - * @event Client#warn - * @prop {String} message The warning message - * @prop {Number} id The ID of the shard - */ + * Fired to warn of something weird but non-breaking happening + * @event Client#warn + * @prop {String} message The warning message + * @prop {Number} id The ID of the shard + */ this.emit("warn", `Non-consecutive sequence (${this.seq} -> ${packet.s})`, this.id); } this.seq = packet.s; @@ -442,11 +442,11 @@ class Shard extends EventEmitter { this.heartbeat(); } /** - * Fired when a shard receives an OP:10/HELLO packet - * @event Client#hello - * @prop {Array} trace The Discord server trace of the gateway and session servers - * @prop {Number} id The ID of the shard - */ + * Fired when a shard receives an OP:10/HELLO packet + * @event Client#hello + * @prop {Array} trace The Discord server trace of the gateway and session servers + * @prop {Number} id The ID of the shard + */ this.emit("hello", packet.d._trace, this.id); break; /* eslint-enable no-unreachable */ } @@ -595,11 +595,11 @@ class Shard extends EventEmitter { } /** - * Fired when an auto moderation action is executed. - * @event Client#autoModerationActionExecution - * @prop {Guild} guild The guild associated with the action - * @prop {Object} action The execution action - */ + * Fired when an auto moderation action is executed. + * @event Client#autoModerationActionExecution + * @prop {Guild} guild The guild associated with the action + * @prop {Object} action The execution action + */ this.emit("autoModerationActionExecution", guild, { action: packet.d.action, alertSystemMessageID: packet.d.alert_system_message_id, @@ -624,11 +624,11 @@ class Shard extends EventEmitter { } /** - * Fired when an auto moderation rule is created - * @event Client#autoModerationRuleCreate - * @prop {Guild} guild The guild associated with the rule - * @prop {AutoModerationRule} rule The created rule - */ + * Fired when an auto moderation rule is created + * @event Client#autoModerationRuleCreate + * @prop {Guild} guild The guild associated with the rule + * @prop {AutoModerationRule} rule The created rule + */ this.emit("autoModerationRuleCreate", guild, new AutoModerationRule(packet.d, this.client)); break; } @@ -640,11 +640,11 @@ class Shard extends EventEmitter { } /** - * Fired when an auto moderation rule is deleted - * @event Client#autoModerationRuleDelete - * @prop {Guild} guild The guild associated with the rule - * @prop {AutoModerationRule} rule The deleted rule - */ + * Fired when an auto moderation rule is deleted + * @event Client#autoModerationRuleDelete + * @prop {Guild} guild The guild associated with the rule + * @prop {AutoModerationRule} rule The deleted rule + */ this.emit("autoModerationRuleDelete", guild, new AutoModerationRule(packet.d, this.client)); break; } @@ -656,12 +656,12 @@ class Shard extends EventEmitter { } /** - * Fired when an auto moderation rule is updated - * @event Client#autoModerationRuleUpdate - * @prop {Guild} guild The guild associated with the rule - * @prop {AutoModerationRule?} rule The old rule, null if uncached - * @prop {AutoModerationRule} newRule The new rule - */ + * Fired when an auto moderation rule is updated + * @event Client#autoModerationRuleUpdate + * @prop {Guild} guild The guild associated with the rule + * @prop {AutoModerationRule?} rule The old rule, null if uncached + * @prop {AutoModerationRule} newRule The new rule + */ this.emit("autoModerationRuleUpdate", guild, null, new AutoModerationRule(packet.d, this.client)); break; } @@ -686,16 +686,16 @@ class Shard extends EventEmitter { if(!user || oldUser) { user = this.client.users.update(packet.d.user, this.client); /** - * Fired when a user's avatar, discriminator or username changes - * @event Client#userUpdate - * @prop {User} user The updated user - * @prop {Object?} oldUser The old user data. If the user was uncached, this will be null - * @prop {String} oldUser.username The username of the user - * @prop {String} oldUser.discriminator The discriminator of the user - * @prop {String?} oldUser.avatar The hash of the user's avatar, or null if no avatar - * @prop {String?} oldUser.globalName The globally visible display name of the user - * @prop {Object?} oldUser.avatarDecorationData The data of the user's avatar decoration, or null if there is no avatar decoration - */ + * Fired when a user's avatar, discriminator or username changes + * @event Client#userUpdate + * @prop {User} user The updated user + * @prop {Object?} oldUser The old user data. If the user was uncached, this will be null + * @prop {String} oldUser.username The username of the user + * @prop {String} oldUser.discriminator The discriminator of the user + * @prop {String?} oldUser.avatar The hash of the user's avatar, or null if no avatar + * @prop {String?} oldUser.globalName The globally visible display name of the user + * @prop {Object?} oldUser.avatarDecorationData The data of the user's avatar decoration, or null if there is no avatar decoration + */ this.emit("userUpdate", user, oldUser); } } @@ -716,17 +716,17 @@ class Shard extends EventEmitter { if((!member && packet.d.user.username) || oldPresence) { member = guild.members.update(packet.d, guild); /** - * Fired when a guild member's status or game changes - * @event Client#presenceUpdate - * @prop {Member} other The updated member - * @prop {Object?} oldPresence The old presence data. If the user was offline when the bot started and the client option getAllUsers is not true, this will be null - * @prop {Array?} oldPresence.activities The member's current activities - * @prop {Object?} oldPresence.clientStatus The member's per-client status - * @prop {String} oldPresence.clientStatus.web The member's status on web. Either "online", "idle", "dnd", or "offline". Will be "online" for bots - * @prop {String} oldPresence.clientStatus.desktop The member's status on desktop. Either "online", "idle", "dnd", or "offline". Will be "offline" for bots - * @prop {String} oldPresence.clientStatus.mobile The member's status on mobile. Either "online", "idle", "dnd", or "offline". Will be "offline" for bots - * @prop {String} oldPresence.status The other user's old status. Either "online", "idle", or "offline" - */ + * Fired when a guild member's status or game changes + * @event Client#presenceUpdate + * @prop {Member} other The updated member + * @prop {Object?} oldPresence The old presence data. If the user was offline when the bot started and the client option getAllUsers is not true, this will be null + * @prop {Array?} oldPresence.activities The member's current activities + * @prop {Object?} oldPresence.clientStatus The member's per-client status + * @prop {String} oldPresence.clientStatus.web The member's status on web. Either "online", "idle", "dnd", or "offline". Will be "online" for bots + * @prop {String} oldPresence.clientStatus.desktop The member's status on desktop. Either "online", "idle", "dnd", or "offline". Will be "offline" for bots + * @prop {String} oldPresence.clientStatus.mobile The member's status on mobile. Either "online", "idle", "dnd", or "offline". Will be "offline" for bots + * @prop {String} oldPresence.status The other user's old status. Either "online", "idle", or "offline" + */ this.emit("presenceUpdate", member, oldPresence); } break; @@ -797,47 +797,47 @@ class Shard extends EventEmitter { if(packet.d.channel_id && (newChannel = guild.channels.get(packet.d.channel_id)) && (newChannel.type === ChannelTypes.GUILD_VOICE || newChannel.type === ChannelTypes.GUILD_STAGE_VOICE)) { // Welcome to Discord, where one can "join" text channels if(oldChannel) { /** - * Fired when a guild member switches voice channels - * @event Client#voiceChannelSwitch - * @prop {Member} member The member - * @prop {TextVoiceChannel | StageChannel} newChannel The new voice channel - * @prop {TextVoiceChannel | StageChannel} oldChannel The old voice channel - */ + * Fired when a guild member switches voice channels + * @event Client#voiceChannelSwitch + * @prop {Member} member The member + * @prop {TextVoiceChannel | StageChannel} newChannel The new voice channel + * @prop {TextVoiceChannel | StageChannel} oldChannel The old voice channel + */ oldChannel.voiceMembers.remove(member); this.emit("voiceChannelSwitch", newChannel.voiceMembers.add(member, guild), newChannel, oldChannel); } else { /** - * Fired when a guild member joins a voice channel. This event is not fired when a member switches voice channels, see `voiceChannelSwitch` - * @event Client#voiceChannelJoin - * @prop {Member} member The member - * @prop {TextVoiceChannel | StageChannel} newChannel The voice channel - */ + * Fired when a guild member joins a voice channel. This event is not fired when a member switches voice channels, see `voiceChannelSwitch` + * @event Client#voiceChannelJoin + * @prop {Member} member The member + * @prop {TextVoiceChannel | StageChannel} newChannel The voice channel + */ this.emit("voiceChannelJoin", newChannel.voiceMembers.add(member, guild), newChannel); } } else if(oldChannel) { oldChannel.voiceMembers.remove(member); /** - * Fired when a guild member leaves a voice channel. This event is not fired when a member switches voice channels, see `voiceChannelSwitch` - * @event Client#voiceChannelLeave - * @prop {Member?} member The member - * @prop {TextVoiceChannel | StageChannel} oldChannel The voice channel - */ + * Fired when a guild member leaves a voice channel. This event is not fired when a member switches voice channels, see `voiceChannelSwitch` + * @event Client#voiceChannelLeave + * @prop {Member?} member The member + * @prop {TextVoiceChannel | StageChannel} oldChannel The voice channel + */ this.emit("voiceChannelLeave", member, oldChannel); } } if(oldState.mute !== member.voiceState.mute || oldState.deaf !== member.voiceState.deaf || oldState.selfMute !== member.voiceState.selfMute || oldState.selfDeaf !== member.voiceState.selfDeaf || oldState.selfStream !== member.voiceState.selfStream || oldState.selfVideo !== member.voiceState.selfVideo) { /** - * Fired when a guild member's voice state changes - * @event Client#voiceStateUpdate - * @prop {Member | Object} member The member. If the member is not cached and Discord doesn't send a member payload, this will be an object with `id` and `voiceState` keys. No other property is guaranteed - * @prop {Object?} oldState The old voice state of the member. If the above caveat applies, this will be null - * @prop {Boolean} oldState.deaf The previous server deaf status - * @prop {Boolean} oldState.mute The previous server mute status - * @prop {Boolean} oldState.selfDeaf The previous self deaf status - * @prop {Boolean} oldState.selfMute The previous self mute status - * @prop {Boolean} oldState.selfStream The previous self stream status - * @prop {Boolean} oldState.selfVideo The previous self video status - */ + * Fired when a guild member's voice state changes + * @event Client#voiceStateUpdate + * @prop {Member | Object} member The member. If the member is not cached and Discord doesn't send a member payload, this will be an object with `id` and `voiceState` keys. No other property is guaranteed + * @prop {Object?} oldState The old voice state of the member. If the above caveat applies, this will be null + * @prop {Boolean} oldState.deaf The previous server deaf status + * @prop {Boolean} oldState.mute The previous server mute status + * @prop {Boolean} oldState.selfDeaf The previous self deaf status + * @prop {Boolean} oldState.selfMute The previous self mute status + * @prop {Boolean} oldState.selfStream The previous self stream status + * @prop {Boolean} oldState.selfVideo The previous self video status + */ this.emit("voiceStateUpdate", member, oldState); } break; @@ -851,12 +851,12 @@ class Shard extends EventEmitter { } if(this.client.listeners("typingStart").length > 0) { /** - * Fired when a user begins typing - * @event Client#typingStart - * @prop {PrivateChannel | TextChannel | NewsChannel | Object} channel The text channel the user is typing in. If the channel is not cached, this will be an object with an `id` key. No other property is guaranteed - * @prop {User | Object} user The user. If the user is not cached, this will be an object with an `id` key. No other property is guaranteed - * @prop {Member?} member The guild member, if typing in a guild channel, or `null`, if typing in a PrivateChannel - */ + * Fired when a user begins typing + * @event Client#typingStart + * @prop {PrivateChannel | TextChannel | NewsChannel | Object} channel The text channel the user is typing in. If the channel is not cached, this will be an object with an `id` key. No other property is guaranteed + * @prop {User | Object} user The user. If the user is not cached, this will be an object with an `id` key. No other property is guaranteed + * @prop {Member?} member The guild member, if typing in a guild channel, or `null`, if typing in a PrivateChannel + */ this.emit("typingStart", this.client.getChannel(packet.d.channel_id) || {id: packet.d.channel_id}, this.client.users.get(packet.d.user_id) || {id: packet.d.user_id}, member); } break; @@ -870,10 +870,10 @@ class Shard extends EventEmitter { channel.totalMessageSent++; } /** - * Fired when a message is created - * @event Client#messageCreate - * @prop {Message} message The message. - */ + * Fired when a message is created + * @event Client#messageCreate + * @prop {Message} message The message. + */ this.emit("messageCreate", channel.messages.add(packet.d, this.client)); } else { this.emit("messageCreate", new Message(packet.d, this.client)); @@ -911,22 +911,22 @@ class Shard extends EventEmitter { break; } /** - * Fired when a message is updated - * @event Client#messageUpdate - * @prop {Message} message The updated message. If oldMessage is null, it is recommended to discard this event, since the message data will be very incomplete (only `id` and `channel` are guaranteed). If the channel isn't cached, `channel` will be an object with an `id` key. - * @prop {Object?} oldMessage The old message data. If the message was cached, this will return the full old message. Otherwise, it will be null - * @prop {Array} oldMessage.attachments Array of attachments - * @prop {Array} oldMessage.channelMentions Array of mentions channels' ids. - * @prop {Array} oldMessage.components An array of message components - * @prop {String} oldMessage.content Message content - * @prop {Number} oldMessage.editedTimestamp Timestamp of latest message edit - * @prop {Array} oldMessage.embeds Array of embeds - * @prop {Number} oldMessage.flags Old message flags (see constants) - * @prop {Array} oldMessage.mentions Array of mentioned users' ids - * @prop {Boolean} oldMessage.pinned Whether the message was pinned or not - * @prop {Array} oldMessage.roleMentions Array of mentioned roles' ids. - * @prop {Boolean} oldMessage.tts Whether to play the message using TTS or not - */ + * Fired when a message is updated + * @event Client#messageUpdate + * @prop {Message} message The updated message. If oldMessage is null, it is recommended to discard this event, since the message data will be very incomplete (only `id` and `channel` are guaranteed). If the channel isn't cached, `channel` will be an object with an `id` key. + * @prop {Object?} oldMessage The old message data. If the message was cached, this will return the full old message. Otherwise, it will be null + * @prop {Array} oldMessage.attachments Array of attachments + * @prop {Array} oldMessage.channelMentions Array of mentions channels' ids. + * @prop {Array} oldMessage.components An array of message components + * @prop {String} oldMessage.content Message content + * @prop {Number} oldMessage.editedTimestamp Timestamp of latest message edit + * @prop {Array} oldMessage.embeds Array of embeds + * @prop {Number} oldMessage.flags Old message flags (see constants) + * @prop {Array} oldMessage.mentions Array of mentioned users' ids + * @prop {Boolean} oldMessage.pinned Whether the message was pinned or not + * @prop {Array} oldMessage.roleMentions Array of mentioned roles' ids. + * @prop {Boolean} oldMessage.tts Whether to play the message using TTS or not + */ this.emit("messageUpdate", channel.messages.update(packet.d, this.client), oldMessage); break; } @@ -937,10 +937,10 @@ class Shard extends EventEmitter { } /** - * Fired when a cached message is deleted - * @event Client#messageDelete - * @prop {Message | Object} message The message object. If the message is not cached, this will be an object with `id` and `channel` keys. If the channel is not cached, channel will be an object with an `id` key. If the uncached message is from a guild, the message will also contain a `guildID` key, and the channel will contain a `guild` with an `id` key. No other property is guaranteed. - */ + * Fired when a cached message is deleted + * @event Client#messageDelete + * @prop {Message | Object} message The message object. If the message is not cached, this will be an object with `id` and `channel` keys. If the channel is not cached, channel will be an object with an `id` key. If the uncached message is from a guild, the message will also contain a `guildID` key, and the channel will contain a `guild` with an `id` key. No other property is guaranteed. + */ this.emit("messageDelete", channel?.messages.remove(packet.d) || { id: packet.d.id, channel: channel || { @@ -958,10 +958,10 @@ class Shard extends EventEmitter { } /** - * Fired when a bulk delete occurs - * @event Client#messageDeleteBulk - * @prop {Array | Array} messages An array of (potentially partial) message objects. If a message is not cached, it will be an object with `id` and `channel` keys If the uncached messages are from a guild, the messages will also contain a `guildID` key, and the channel will contain a `guild` with an `id` key. No other property is guaranteed - */ + * Fired when a bulk delete occurs + * @event Client#messageDeleteBulk + * @prop {Array | Array} messages An array of (potentially partial) message objects. If a message is not cached, it will be an object with `id` and `channel` keys If the uncached messages are from a guild, the messages will also contain a `guildID` key, and the channel will contain a `guild` with an `id` key. No other property is guaranteed + */ this.emit("messageDeleteBulk", packet.d.ids.map((id) => (channel?.messages.remove({ id }) || { @@ -1024,16 +1024,16 @@ class Shard extends EventEmitter { } } /** - * Fired when someone adds a reaction to a message - * @event Client#messageReactionAdd - * @prop {Message | Object} message The message object. If the message is not cached, this will be an object with `id`, `channel`, `author` (if present in the payload), and if inside a guild, `guildID` keys. If the channel is not cached, channel key will be an object with only an id. If the author is not cached, the author key will be an object with only an ID. `guildID` will be present if the message was sent in a guild channel. No other property is guaranteed - * @prop {Object} emoji The reaction emoji object - * @prop {Boolean?} emoji.animated Whether the emoji is animated or not - * @prop {String?} emoji.id The emoji ID (null for non-custom emojis) - * @prop {String} emoji.name The emoji name - * @prop {Member | Object} reactor The member, if the reaction is in a guild. If the reaction is not in a guild, this will be an object with an `id` key. No other property is guaranteed - * @prop {Boolean} isBurst Whether the reaction is a super-reaction or not - */ + * Fired when someone adds a reaction to a message + * @event Client#messageReactionAdd + * @prop {Message | Object} message The message object. If the message is not cached, this will be an object with `id`, `channel`, `author` (if present in the payload), and if inside a guild, `guildID` keys. If the channel is not cached, channel key will be an object with only an id. If the author is not cached, the author key will be an object with only an ID. `guildID` will be present if the message was sent in a guild channel. No other property is guaranteed + * @prop {Object} emoji The reaction emoji object + * @prop {Boolean?} emoji.animated Whether the emoji is animated or not + * @prop {String?} emoji.id The emoji ID (null for non-custom emojis) + * @prop {String} emoji.name The emoji name + * @prop {Member | Object} reactor The member, if the reaction is in a guild. If the reaction is not in a guild, this will be an object with an `id` key. No other property is guaranteed + * @prop {Boolean} isBurst Whether the reaction is a super-reaction or not + */ this.emit("messageReactionAdd", message, packet.d.emoji, member || {id: packet.d.user_id}, !!packet.d.burst); break; } @@ -1068,16 +1068,16 @@ class Shard extends EventEmitter { } } /** - * Fired when someone removes a reaction from a message - * @event Client#messageReactionRemove - * @prop {Message | Object} message The message object. If the message is not cached, this will be an object with `id`, `channel`, and if inside a guild, `guildID` keys. If the channel is not cached, channel key will be an object with only an id. `guildID` will be present if the message was sent in a guild channel. No other property is guaranteed - * @prop {Object} emoji The reaction emoji object - * @prop {Boolean?} emoji.animated Whether the emoji is animated or not - * @prop {String?} emoji.id The ID of the emoji (null for non-custom emojis) - * @prop {String} emoji.name The emoji name - * @prop {String} userID The ID of the user that removed the reaction - * @prop {Boolean} isBurst Whether the removed reaction is a super-reaction or not - */ + * Fired when someone removes a reaction from a message + * @event Client#messageReactionRemove + * @prop {Message | Object} message The message object. If the message is not cached, this will be an object with `id`, `channel`, and if inside a guild, `guildID` keys. If the channel is not cached, channel key will be an object with only an id. `guildID` will be present if the message was sent in a guild channel. No other property is guaranteed + * @prop {Object} emoji The reaction emoji object + * @prop {Boolean?} emoji.animated Whether the emoji is animated or not + * @prop {String?} emoji.id The ID of the emoji (null for non-custom emojis) + * @prop {String} emoji.name The emoji name + * @prop {String} userID The ID of the user that removed the reaction + * @prop {Boolean} isBurst Whether the removed reaction is a super-reaction or not + */ this.emit("messageReactionRemove", message, packet.d.emoji, packet.d.user_id, !!packet.d.burst); break; } @@ -1098,10 +1098,10 @@ class Shard extends EventEmitter { } } /** - * Fired when all reactions are removed from a message - * @event Client#messageReactionRemoveAll - * @prop {Message | Object} message The message object. If the message is not cached, this will be an object with `id`, `channel`, and if inside a guild, `guildID` keys. If the channel is not cached, channel key will be an object with only an id. No other property is guaranteed - */ + * Fired when all reactions are removed from a message + * @event Client#messageReactionRemoveAll + * @prop {Message | Object} message The message object. If the message is not cached, this will be an object with `id`, `channel`, and if inside a guild, `guildID` keys. If the channel is not cached, channel key will be an object with only an id. No other property is guaranteed + */ this.emit("messageReactionRemoveAll", message); break; } @@ -1123,14 +1123,14 @@ class Shard extends EventEmitter { } } /** - * Fired when someone removes all reactions from a message for a single emoji - * @event Client#messageReactionRemoveEmoji - * @prop {Message | Object} message The message object. If the message is not cached, this will be an object with `id` and `channel` keys. If the channel is not cached, channel key will be an object with only an id. No other property is guaranteed - * @prop {Object} emoji The reaction emoji object - * @prop {Boolean?} emoji.animated Whether the emoji is animated or not - * @prop {String?} emoji.id The ID of the emoji (null for non-custom emojis) - * @prop {String} emoji.name The emoji name - */ + * Fired when someone removes all reactions from a message for a single emoji + * @event Client#messageReactionRemoveEmoji + * @prop {Message | Object} message The message object. If the message is not cached, this will be an object with `id` and `channel` keys. If the channel is not cached, channel key will be an object with only an id. No other property is guaranteed + * @prop {Object} emoji The reaction emoji object + * @prop {Boolean?} emoji.animated Whether the emoji is animated or not + * @prop {String?} emoji.id The ID of the emoji (null for non-custom emojis) + * @prop {String} emoji.name The emoji name + */ this.emit("messageReactionRemoveEmoji", message, packet.d.emoji); break; } @@ -1143,11 +1143,11 @@ class Shard extends EventEmitter { packet.d.id = packet.d.user.id; ++guild.memberCount; /** - * Fired when a member joins a server - * @event Client#guildMemberAdd - * @prop {Guild} guild The guild - * @prop {Member} member The member - */ + * Fired when a member joins a server + * @event Client#guildMemberAdd + * @prop {Guild} guild The guild + * @prop {Member} member The member + */ this.emit("guildMemberAdd", guild, guild.members.add(packet.d, guild)); break; } @@ -1195,19 +1195,19 @@ class Shard extends EventEmitter { } member = guild.members.update(packet.d, guild); /** - * Fired when a member's guild avatar, roles or nickname are updated or they start boosting a server - * @event Client#guildMemberUpdate - * @prop {Guild} guild The guild - * @prop {Member} member The updated member - * @prop {Object?} oldMember The old member data, or null if the member wasn't cached - * @prop {String?} oldMember.avatar The hash of the member's guild avatar, or null if no guild avatar - * @prop {Number?} oldMember.communicationDisabledUntil Timestamp of previous timeout expiry. If `null`, the member was not timed out - * @prop {Number} oldMember.flags The guild member flag bit set - * @prop {String?} oldMember.nick The server nickname of the member - * @prop {Number?} oldMember.premiumSince Timestamp of when the member boosted the guild - * @prop {Boolean?} oldMember.pending Whether the member has passed the guild's Membership Screening requirements - * @prop {Array} oldMember.roles An array of role IDs this member is a part of - */ + * Fired when a member's guild avatar, roles or nickname are updated or they start boosting a server + * @event Client#guildMemberUpdate + * @prop {Guild} guild The guild + * @prop {Member} member The updated member + * @prop {Object?} oldMember The old member data, or null if the member wasn't cached + * @prop {String?} oldMember.avatar The hash of the member's guild avatar, or null if no guild avatar + * @prop {Number?} oldMember.communicationDisabledUntil Timestamp of previous timeout expiry. If `null`, the member was not timed out + * @prop {Number} oldMember.flags The guild member flag bit set + * @prop {String?} oldMember.nick The server nickname of the member + * @prop {Number?} oldMember.premiumSince Timestamp of when the member boosted the guild + * @prop {Boolean?} oldMember.pending Whether the member has passed the guild's Membership Screening requirements + * @prop {Array} oldMember.roles An array of role IDs this member is a part of + */ this.emit("guildMemberUpdate", guild, member, oldMember); break; } @@ -1222,11 +1222,11 @@ class Shard extends EventEmitter { --guild.memberCount; packet.d.id = packet.d.user.id; /** - * Fired when a member leaves a server - * @event Client#guildMemberRemove - * @prop {Guild} guild The guild - * @prop {Member | Object} member The member. If the member is not cached, this will be an object with `id` and `user` key - */ + * Fired when a member leaves a server + * @event Client#guildMemberRemove + * @prop {Guild} guild The guild + * @prop {Member | Object} member The member. If the member is not cached, this will be an object with `id` and `user` key + */ this.emit("guildMemberRemove", guild, guild.members.remove(packet.d) || { id: packet.d.id, user: new User(packet.d.user, this.client) @@ -1239,19 +1239,19 @@ class Shard extends EventEmitter { if(this.ready) { if(this.client.unavailableGuilds.remove(packet.d)) { /** - * Fired when a guild becomes available - * @event Client#guildAvailable - * @prop {Guild} guild The guild - */ + * Fired when a guild becomes available + * @event Client#guildAvailable + * @prop {Guild} guild The guild + */ this.emit("guildAvailable", guild); } else { /** - * Fired when a guild is created. This happens when: - * - the client creates a guild - * - the client joins a guild - * @event Client#guildCreate - * @prop {Guild} guild The guild - */ + * Fired when a guild is created. This happens when: + * - the client creates a guild + * - the client joins a guild + * @event Client#guildCreate + * @prop {Guild} guild The guild + */ this.emit("guildCreate", guild); } } else { @@ -1261,10 +1261,10 @@ class Shard extends EventEmitter { } else { this.client.guilds.remove(packet.d); /** - * Fired when an unavailable guild is created - * @event Client#unavailableGuildCreate - * @prop {UnavailableGuild} guild The unavailable guild - */ + * Fired when an unavailable guild is created + * @event Client#unavailableGuildCreate + * @prop {UnavailableGuild} guild The unavailable guild + */ this.emit("unavailableGuildCreate", this.client.unavailableGuilds.add(packet.d, this.client)); } break; @@ -1313,40 +1313,40 @@ class Shard extends EventEmitter { } }; /** - * Fired when a guild is updated - * @event Client#guildUpdate - * @prop {Guild} guild The guild - * @prop {Object} oldGuild The old guild data - * @prop {String?} oldGuild.afkChannelID The ID of the AFK voice channel - * @prop {Number} oldGuild.afkTimeout The AFK timeout in seconds - * @prop {String?} oldGuild.banner The hash of the guild banner image, or null if no splash (VIP only) - * @prop {Number} oldGuild.defaultNotifications The default notification settings for the guild. 0 is "All Messages", 1 is "Only @mentions" - * @prop {String?} oldGuild.description The description for the guild (VIP only) - * @prop {Array} oldGuild.emojis An array of guild emojis - * @prop {Number} oldGuild.explicitContentFilter The explicit content filter level for the guild. 0 is off, 1 is on for people without roles, 2 is on for all - * @prop {Array} oldGuild.features An array of guild features - * @prop {String?} oldGuild.icon The hash of the guild icon, or null if no icon - * @prop {Boolean} oldGuild.large Whether the guild is "large" by "some Discord standard" - * @prop {Number?} oldGuild.maxMembers The maximum number of members for this guild - * @prop {Number?} oldGuild.maxStageVideoChannelUsers The max number of users allowed in a stage video channel - * @prop {Number?} oldGuild.maxVideoChannelUsers The max number of users allowed in a video channel - * @prop {Number} oldGuild.mfaLevel The admin 2FA level for the guild. 0 is not required, 1 is required - * @prop {String} oldGuild.name The name of the guild - * @prop {Number} oldGuild.nsfwLevel The guild NSFW level designated by Discord - * @prop {String} oldGuild.ownerID The ID of the user that is the guild owner - * @prop {String} oldGuild.preferredLocale Preferred "COMMUNITY" guild language used in server discovery and notices from Discord - * @prop {Number?} oldGuild.premiumSubscriptionCount The total number of users currently boosting this guild - * @prop {Number} oldGuild.premiumTier Nitro boost level of the guild - * @prop {String?} oldGuild.publicUpdatesChannelID ID of the guild's updates channel if the guild has "COMMUNITY" features - * @prop {String?} oldGuild.rulesChannelID The channel where "COMMUNITY" guilds display rules and/or guidelines - * @prop {String?} oldGuild.safetyAlertsChannelID The ID of the channel where safety alerts from Discord are received - * @prop {String?} oldGuild.splash The hash of the guild splash image, or null if no splash (VIP only) - * @prop {Array?} stickers An array of guild sticker objects - * @prop {Number} oldGuild.systemChannelFlags the flags for the system channel - * @prop {String?} oldGuild.systemChannelID The ID of the default channel for system messages (built-in join messages and boost messages) - * @prop {String?} oldGuild.vanityURL The vanity URL of the guild (VIP only) - * @prop {Number} oldGuild.verificationLevel The guild verification level - */ + * Fired when a guild is updated + * @event Client#guildUpdate + * @prop {Guild} guild The guild + * @prop {Object} oldGuild The old guild data + * @prop {String?} oldGuild.afkChannelID The ID of the AFK voice channel + * @prop {Number} oldGuild.afkTimeout The AFK timeout in seconds + * @prop {String?} oldGuild.banner The hash of the guild banner image, or null if no splash (VIP only) + * @prop {Number} oldGuild.defaultNotifications The default notification settings for the guild. 0 is "All Messages", 1 is "Only @mentions" + * @prop {String?} oldGuild.description The description for the guild (VIP only) + * @prop {Array} oldGuild.emojis An array of guild emojis + * @prop {Number} oldGuild.explicitContentFilter The explicit content filter level for the guild. 0 is off, 1 is on for people without roles, 2 is on for all + * @prop {Array} oldGuild.features An array of guild features + * @prop {String?} oldGuild.icon The hash of the guild icon, or null if no icon + * @prop {Boolean} oldGuild.large Whether the guild is "large" by "some Discord standard" + * @prop {Number?} oldGuild.maxMembers The maximum number of members for this guild + * @prop {Number?} oldGuild.maxStageVideoChannelUsers The max number of users allowed in a stage video channel + * @prop {Number?} oldGuild.maxVideoChannelUsers The max number of users allowed in a video channel + * @prop {Number} oldGuild.mfaLevel The admin 2FA level for the guild. 0 is not required, 1 is required + * @prop {String} oldGuild.name The name of the guild + * @prop {Number} oldGuild.nsfwLevel The guild NSFW level designated by Discord + * @prop {String} oldGuild.ownerID The ID of the user that is the guild owner + * @prop {String} oldGuild.preferredLocale Preferred "COMMUNITY" guild language used in server discovery and notices from Discord + * @prop {Number?} oldGuild.premiumSubscriptionCount The total number of users currently boosting this guild + * @prop {Number} oldGuild.premiumTier Nitro boost level of the guild + * @prop {String?} oldGuild.publicUpdatesChannelID ID of the guild's updates channel if the guild has "COMMUNITY" features + * @prop {String?} oldGuild.rulesChannelID The channel where "COMMUNITY" guilds display rules and/or guidelines + * @prop {String?} oldGuild.safetyAlertsChannelID The ID of the channel where safety alerts from Discord are received + * @prop {String?} oldGuild.splash The hash of the guild splash image, or null if no splash (VIP only) + * @prop {Array?} stickers An array of guild sticker objects + * @prop {Number} oldGuild.systemChannelFlags the flags for the system channel + * @prop {String?} oldGuild.systemChannelID The ID of the default channel for system messages (built-in join messages and boost messages) + * @prop {String?} oldGuild.vanityURL The vanity URL of the guild (VIP only) + * @prop {Number} oldGuild.verificationLevel The guild verification level + */ this.emit("guildUpdate", this.client.guilds.update(packet.d, this.client), oldGuild); break; } @@ -1362,25 +1362,25 @@ class Shard extends EventEmitter { delete this.client.guildShardMap[packet.d.id]; const guild = this.client.guilds.remove(packet.d); - guild?.channels.forEach((channel) => { // Discord sends GUILD_DELETE for guilds that were previously unavailable in READY + guild?.channels.forEach((channel) => { // Discord sends GUILD_DELETE for guilds that were previously unavailable in READY delete this.client.channelGuildMap[channel.id]; }); if(packet.d.unavailable) { /** - * Fired when a guild becomes unavailable - * @event Client#guildUnavailable - * @prop {Guild} guild The guild - */ + * Fired when a guild becomes unavailable + * @event Client#guildUnavailable + * @prop {Guild} guild The guild + */ this.emit("guildUnavailable", this.client.unavailableGuilds.add(packet.d, this.client)); } else { /** - * Fired when a guild is deleted. This happens when: - * - the client left the guild - * - the client was kicked/banned from the guild - * - the guild was literally deleted - * @event Client#guildDelete - * @prop {Guild | Object} guild The guild. If the guild was not cached, it will be an object with an `id` key. No other property is guaranteed - */ + * Fired when a guild is deleted. This happens when: + * - the client left the guild + * - the client was kicked/banned from the guild + * - the guild was literally deleted + * @event Client#guildDelete + * @prop {Guild | Object} guild The guild. If the guild was not cached, it will be an object with an `id` key. No other property is guaranteed + */ this.emit("guildDelete", guild || { id: packet.d.id }); @@ -1389,11 +1389,11 @@ class Shard extends EventEmitter { } case "GUILD_BAN_ADD": { /** - * Fired when a user is banned from a guild - * @event Client#guildBanAdd - * @prop {Guild} guild The guild - if uncached, this will be an object with the guild's ID. No other properties are guaranteed - * @prop {User} user The banned user - */ + * Fired when a user is banned from a guild + * @event Client#guildBanAdd + * @prop {Guild} guild The guild - if uncached, this will be an object with the guild's ID. No other properties are guaranteed + * @prop {User} user The banned user + */ this.emit("guildBanAdd", this.client.guilds.get(packet.d.guild_id) || { id: packet.d.guild_id }, this.client.users.update(packet.d.user, this.client)); @@ -1401,11 +1401,11 @@ class Shard extends EventEmitter { } case "GUILD_BAN_REMOVE": { /** - * Fired when a user is unbanned from a guild - * @event Client#guildBanRemove - * @prop {Guild} guild The guild - if uncached, this will be an object with the guild's ID. No other properties are guaranteed - * @prop {User} user The banned user - */ + * Fired when a user is unbanned from a guild + * @event Client#guildBanRemove + * @prop {Guild} guild The guild - if uncached, this will be an object with the guild's ID. No other properties are guaranteed + * @prop {User} user The banned user + */ this.emit("guildBanRemove", this.client.guilds.get(packet.d.guild_id) || { id: packet.d.guild_id }, this.client.users.update(packet.d.user, this.client)); @@ -1413,11 +1413,11 @@ class Shard extends EventEmitter { } case "GUILD_ROLE_CREATE": { /** - * Fired when a guild role is created - * @event Client#guildRoleCreate - * @prop {Guild} guild The guild - * @prop {Role} role The role - */ + * Fired when a guild role is created + * @event Client#guildRoleCreate + * @prop {Guild} guild The guild + * @prop {Role} role The role + */ const guild = this.client.guilds.get(packet.d.guild_id); if(!guild) { this.emit("debug", `Missing guild ${packet.d.guild_id} in GUILD_ROLE_CREATE`); @@ -1451,33 +1451,33 @@ class Shard extends EventEmitter { unicodeEmoji: role.unicodeEmoji }; /** - * Fired when a guild role is updated - * @event Client#guildRoleUpdate - * @prop {Guild} guild The guild - * @prop {Role} role The updated role - * @prop {Object} oldRole The old role data - * @prop {Number} oldRole.color The hex color of the role in base 10 - * @prop {Number} oldRole.flags Role flags. See [Discord's documentation](https://discord.com/developers/docs/topics/permissions#role-object-role-flags) for a list of them - * @prop {Boolean} oldRole.hoist Whether users with this role are hoisted in the user list or not - * @prop {String?} oldRole.icon The hash of the role's icon, or null if no icon - * @prop {Boolean} oldRole.managed Whether a guild integration manages this role or not - * @prop {Boolean} oldRole.mentionable Whether the role is mentionable or not - * @prop {String} oldRole.name The name of the role - * @prop {Permission} oldRole.permissions The permissions number of the role - * @prop {Number} oldRole.position The position of the role - * @prop {Object?} oldRole.tags The tags of the role - * @prop {String?} oldRole.unicodeEmoji Unicode emoji for the role - */ + * Fired when a guild role is updated + * @event Client#guildRoleUpdate + * @prop {Guild} guild The guild + * @prop {Role} role The updated role + * @prop {Object} oldRole The old role data + * @prop {Number} oldRole.color The hex color of the role in base 10 + * @prop {Number} oldRole.flags Role flags. See [Discord's documentation](https://discord.com/developers/docs/topics/permissions#role-object-role-flags) for a list of them + * @prop {Boolean} oldRole.hoist Whether users with this role are hoisted in the user list or not + * @prop {String?} oldRole.icon The hash of the role's icon, or null if no icon + * @prop {Boolean} oldRole.managed Whether a guild integration manages this role or not + * @prop {Boolean} oldRole.mentionable Whether the role is mentionable or not + * @prop {String} oldRole.name The name of the role + * @prop {Permission} oldRole.permissions The permissions number of the role + * @prop {Number} oldRole.position The position of the role + * @prop {Object?} oldRole.tags The tags of the role + * @prop {String?} oldRole.unicodeEmoji Unicode emoji for the role + */ this.emit("guildRoleUpdate", guild, guild.roles.update(packet.d.role, guild), oldRole); break; } case "GUILD_ROLE_DELETE": { /** - * Fired when a guild role is deleted - * @event Client#guildRoleDelete - * @prop {Guild} guild The guild - * @prop {Role} role The role - */ + * Fired when a guild role is deleted + * @event Client#guildRoleDelete + * @prop {Guild} guild The guild + * @prop {Role} role The role + */ const guild = this.client.guilds.get(packet.d.guild_id); if(!guild) { this.emit("debug", `Missing guild ${packet.d.guild_id} in GUILD_ROLE_DELETE`); @@ -1502,11 +1502,11 @@ class Shard extends EventEmitter { break; } /** - * Fired when a guild invite is created - * @event Client#inviteCreate - * @prop {Guild} guild The guild this invite was created in. - * @prop {Invite} invite The invite that was created - */ + * Fired when a guild invite is created + * @event Client#inviteCreate + * @prop {Guild} guild The guild this invite was created in. + * @prop {Invite} invite The invite that was created + */ this.emit("inviteCreate", guild, new Invite({ ...packet.d, guild, @@ -1526,11 +1526,11 @@ class Shard extends EventEmitter { break; } /** - * Fired when a guild invite is deleted - * @event Client#inviteDelete - * @prop {Guild} guild The guild this invite was created in. - * @prop {Invite} invite The invite that was deleted - */ + * Fired when a guild invite is deleted + * @event Client#inviteDelete + * @prop {Guild} guild The guild this invite was created in. + * @prop {Invite} invite The invite that was deleted + */ this.emit("inviteDelete", guild, new Invite({ ...packet.d, guild, @@ -1549,10 +1549,10 @@ class Shard extends EventEmitter { channel.guild.channels.add(channel, this.client); this.client.channelGuildMap[packet.d.id] = packet.d.guild_id; /** - * Fired when a channel is created - * @event Client#channelCreate - * @prop {TextChannel | TextVoiceChannel | CategoryChannel | NewsChannel | GuildChannel} channel The channel - */ + * Fired when a channel is created + * @event Client#channelCreate + * @prop {TextChannel | TextVoiceChannel | CategoryChannel | NewsChannel | GuildChannel} channel The channel + */ this.emit("channelCreate", channel); } else { this.emit("warn", new Error("Unhandled CHANNEL_CREATE type: " + JSON.stringify(packet, null, 2))); @@ -1616,29 +1616,29 @@ class Shard extends EventEmitter { } /** - * Fired when a channel is updated - * @event Client#channelUpdate - * @prop {TextChannel | TextVoiceChannel | CategoryChannel | NewsChannel | GuildChannel | PrivateChannel} channel The updated channel - * @prop {Object} oldChannel The old channel data - * @prop {Array} oldChannel.availableTags The available tags of the channel (forum channels only) - * @prop {Number} oldChannel.bitrate The bitrate of the channel (voice channels only) - * @prop {Number} oldChannel.defaultAutoArchiveDuration The default duration of newly created threads in minutes to automatically archive the thread after inactivity (60, 1440, 4320, 10080) - * @prop {Object} oldChannel.defaultReactionEmoji The emoji to show as the reaction button - * @prop {Number} oldChannel.defaultSortOrder The default thread sorting order - * @prop {Number} oldChannel.defaultThreadRateLimitPerUser The initial ratelimit of the channel to use on newly created threads, in seconds. 0 means no ratelimit is enabled - * @prop {Number?} oldChannel.flags The flags of the channel - * @prop {String} oldChannel.name The name of the channel - * @prop {Boolean} oldChannel.nsfw Whether the channel is NSFW or not (text channels only) - * @prop {String?} oldChannel.parentID The ID of the category this channel belongs to (guild channels only) - * @prop {Collection} oldChannel.permissionOverwrites Collection of PermissionOverwrites in this channel (guild channels only) - * @prop {Number} oldChannel.position The position of the channel (guild channels only) - * @prop {Number?} oldChannel.rateLimitPerUser The ratelimit of the channel, in seconds. 0 means no ratelimit is enabled (text channels only) - * @prop {String?} oldChannel.rtcRegion The RTC region ID of the channel (automatic when `null`) (voice channels only) - * @prop {String?} oldChannel.topic The topic of the channel (text channels only) - * @prop {Number} oldChannel.type The type of the old channel (text/news channels only) - * @prop {Number?} oldChannel.userLimit The max number of users that can join the channel (voice channels only) - * @prop {Number?} oldChannel.videoQualityMode The camera video quality mode of the channel (voice channels only) - */ + * Fired when a channel is updated + * @event Client#channelUpdate + * @prop {TextChannel | TextVoiceChannel | CategoryChannel | NewsChannel | GuildChannel | PrivateChannel} channel The updated channel + * @prop {Object} oldChannel The old channel data + * @prop {Array} oldChannel.availableTags The available tags of the channel (forum channels only) + * @prop {Number} oldChannel.bitrate The bitrate of the channel (voice channels only) + * @prop {Number} oldChannel.defaultAutoArchiveDuration The default duration of newly created threads in minutes to automatically archive the thread after inactivity (60, 1440, 4320, 10080) + * @prop {Object} oldChannel.defaultReactionEmoji The emoji to show as the reaction button + * @prop {Number} oldChannel.defaultSortOrder The default thread sorting order + * @prop {Number} oldChannel.defaultThreadRateLimitPerUser The initial ratelimit of the channel to use on newly created threads, in seconds. 0 means no ratelimit is enabled + * @prop {Number?} oldChannel.flags The flags of the channel + * @prop {String} oldChannel.name The name of the channel + * @prop {Boolean} oldChannel.nsfw Whether the channel is NSFW or not (text channels only) + * @prop {String?} oldChannel.parentID The ID of the category this channel belongs to (guild channels only) + * @prop {Collection} oldChannel.permissionOverwrites Collection of PermissionOverwrites in this channel (guild channels only) + * @prop {Number} oldChannel.position The position of the channel (guild channels only) + * @prop {Number?} oldChannel.rateLimitPerUser The ratelimit of the channel, in seconds. 0 means no ratelimit is enabled (text channels only) + * @prop {String?} oldChannel.rtcRegion The RTC region ID of the channel (automatic when `null`) (voice channels only) + * @prop {String?} oldChannel.topic The topic of the channel (text channels only) + * @prop {Number} oldChannel.type The type of the old channel (text/news channels only) + * @prop {Number?} oldChannel.userLimit The max number of users that can join the channel (voice channels only) + * @prop {Number?} oldChannel.videoQualityMode The camera video quality mode of the channel (voice channels only) + */ this.emit("channelUpdate", channel, oldChannel); break; } @@ -1649,10 +1649,10 @@ class Shard extends EventEmitter { if(channel) { delete this.client.privateChannelMap[channel.recipient.id]; /** - * Fired when a channel is deleted - * @event Client#channelDelete - * @prop {PrivateChannel | TextChannel | NewsChannel | TextVoiceChannel | CategoryChannel} channel The channel - */ + * Fired when a channel is deleted + * @event Client#channelDelete + * @prop {PrivateChannel | TextChannel | NewsChannel | TextVoiceChannel | CategoryChannel} channel The channel + */ this.emit("channelDelete", channel); } } @@ -1713,11 +1713,11 @@ class Shard extends EventEmitter { } /** - * Fired when Discord sends member chunks - * @event Client#guildMemberChunk - * @prop {Guild} guild The guild the chunked members are in - * @prop {Array} members The members in the chunk - */ + * Fired when Discord sends member chunks + * @event Client#guildMemberChunk + * @prop {Guild} guild The guild the chunked members are in + * @prop {Array} members The members in the chunk + */ this.emit("guildMemberChunk", guild, members); this.lastHeartbeatAck = true; @@ -1746,9 +1746,9 @@ class Shard extends EventEmitter { this.ready = true; /** - * Fired when a shard finishes resuming - * @event Shard#resume - */ + * Fired when a shard finishes resuming + * @event Shard#resume + */ super.emit("resume"); break; } else { @@ -1783,10 +1783,10 @@ class Shard extends EventEmitter { this.preReady = true; /** - * Fired when a shard finishes processing the ready packet - * @event Client#shardPreReady - * @prop {Number} id The ID of the shard - */ + * Fired when a shard finishes processing the ready packet + * @event Client#shardPreReady + * @prop {Number} id The ID of the shard + */ this.emit("shardPreReady", this.id); if(this.client.unavailableGuilds.size > 0 && packet.d.guilds.length > 0) { @@ -1830,12 +1830,12 @@ class Shard extends EventEmitter { emojis = guild.emojis; } /** - * Fired when a guild's emojis are updated - * @event Client#guildEmojisUpdate - * @prop {Guild} guild The guild. If the guild is uncached, this is an object with an ID key. No other property is guaranteed - * @prop {Array} emojis The updated emojis of the guild - * @prop {Array?} oldEmojis The old emojis of the guild. If the guild is uncached, this will be null - */ + * Fired when a guild's emojis are updated + * @event Client#guildEmojisUpdate + * @prop {Guild} guild The guild. If the guild is uncached, this is an object with an ID key. No other property is guaranteed + * @prop {Array} emojis The updated emojis of the guild + * @prop {Array?} oldEmojis The old emojis of the guild. If the guild is uncached, this will be null + */ this.emit("guildEmojisUpdate", guild || {id: packet.d.guild_id}, emojis, oldEmojis); break; } @@ -1849,12 +1849,12 @@ class Shard extends EventEmitter { stickers = guild.stickers; } /** - * Fired when a guild's stickers are updated - * @event Client#guildStickersUpdate - * @prop {Guild} guild The guild. If the guild is uncached, this is an object with an ID key. No other property is guaranteed - * @prop {Array} stickers The updated stickers of the guild - * @prop {Array?} oldStickers The old stickers of the guild. If the guild is uncached, this will be null - */ + * Fired when a guild's stickers are updated + * @event Client#guildStickersUpdate + * @prop {Guild} guild The guild. If the guild is uncached, this is an object with an ID key. No other property is guaranteed + * @prop {Array} stickers The updated stickers of the guild + * @prop {Array?} oldStickers The old stickers of the guild. If the guild is uncached, this will be null + */ this.emit("guildStickersUpdate", guild || {id: packet.d.guild_id}, stickers, oldStickers); break; } @@ -1867,23 +1867,23 @@ class Shard extends EventEmitter { const oldTimestamp = channel.lastPinTimestamp; channel.lastPinTimestamp = Date.parse(packet.d.last_pin_timestamp); /** - * Fired when a channel pin timestamp is updated - * @event Client#channelPinUpdate - * @prop {PrivateChannel | TextChannel | NewsChannel} channel The channel - * @prop {Number} timestamp The new timestamp - * @prop {Number} oldTimestamp The old timestamp - */ + * Fired when a channel pin timestamp is updated + * @event Client#channelPinUpdate + * @prop {PrivateChannel | TextChannel | NewsChannel} channel The channel + * @prop {Number} timestamp The new timestamp + * @prop {Number} oldTimestamp The old timestamp + */ this.emit("channelPinUpdate", channel, channel.lastPinTimestamp, oldTimestamp); break; } case "WEBHOOKS_UPDATE": { /** - * Fired when a channel's webhooks are updated - * @event Client#webhooksUpdate - * @prop {Object} data The update data - * @prop {String} data.channelID The ID of the channel that webhooks were updated in - * @prop {String} data.guildID The ID of the guild that webhooks were updated in - */ + * Fired when a channel's webhooks are updated + * @event Client#webhooksUpdate + * @prop {Object} data The update data + * @prop {String} data.channelID The ID of the channel that webhooks were updated in + * @prop {String} data.guildID The ID of the guild that webhooks were updated in + */ this.emit("webhooksUpdate", { channelID: packet.d.channel_id, guildID: packet.d.guild_id @@ -1905,10 +1905,10 @@ class Shard extends EventEmitter { channel.guild.threads.add(channel, this.client); this.client.threadGuildMap[packet.d.id] = packet.d.guild_id; /** - * Fired when a channel is created - * @event Client#threadCreate - * @prop {NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel} channel The channel - */ + * Fired when a channel is created + * @event Client#threadCreate + * @prop {NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel} channel The channel + */ this.emit("threadCreate", channel); break; } @@ -1934,20 +1934,20 @@ class Shard extends EventEmitter { channel.update(packet.d, this.client); /** - * Fired when a thread channel is updated - * @event Client#threadUpdate - * @prop {NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel} channel The updated channel - * @prop {Object?} oldChannel The old thread channel. This will be null if the channel was uncached - * @prop {Array?} oldChannel.appliedTags An array of applied tag IDs for the thread (available only in threads in thread-only channels) - * @prop {Number?} oldChannel.flags The flags of the channel - * @prop {String} oldChannel.name The name of the channel - * @prop {Number} oldChannel.rateLimitPerUser The ratelimit of the channel, in seconds. 0 means no ratelimit is enabled - * @prop {Object} oldChannel.threadMetadata Metadata for the thread - * @prop {Number} oldChannel.threadMetadata.archiveTimestamp Timestamp when the thread's archive status was last changed, used for calculating recent activity - * @prop {Boolean} oldChannel.threadMetadata.archived Whether the thread is archived - * @prop {Number} oldChannel.threadMetadata.autoArchiveDuration Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080 - * @prop {Boolean?} oldChannel.threadMetadata.locked Whether the thread is locked - */ + * Fired when a thread channel is updated + * @event Client#threadUpdate + * @prop {NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel} channel The updated channel + * @prop {Object?} oldChannel The old thread channel. This will be null if the channel was uncached + * @prop {Array?} oldChannel.appliedTags An array of applied tag IDs for the thread (available only in threads in thread-only channels) + * @prop {Number?} oldChannel.flags The flags of the channel + * @prop {String} oldChannel.name The name of the channel + * @prop {Number} oldChannel.rateLimitPerUser The ratelimit of the channel, in seconds. 0 means no ratelimit is enabled + * @prop {Object} oldChannel.threadMetadata Metadata for the thread + * @prop {Number} oldChannel.threadMetadata.archiveTimestamp Timestamp when the thread's archive status was last changed, used for calculating recent activity + * @prop {Boolean} oldChannel.threadMetadata.archived Whether the thread is archived + * @prop {Number} oldChannel.threadMetadata.autoArchiveDuration Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080 + * @prop {Boolean?} oldChannel.threadMetadata.locked Whether the thread is locked + */ this.emit("threadUpdate", channel, oldChannel); break; } @@ -1963,10 +1963,10 @@ class Shard extends EventEmitter { break; } /** - * Fired when a thread channel is deleted - * @event Client#threadDelete - * @prop {NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel} channel The channel - */ + * Fired when a thread channel is deleted + * @event Client#threadDelete + * @prop {NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel} channel The channel + */ this.emit("threadDelete", channel); break; } @@ -1981,13 +1981,13 @@ class Shard extends EventEmitter { const activeThreads = packet.d.threads.map((t) => guild.threads.update(t, this.client)); const joinedThreadsMember = packet.d.members.map((m) => guild.threads.get(m.id).members.update(m, this.client)); /** - * Fired when the current user gains access to a channel - * @event Client#threadListSync - * @prop {Guild} guild The guild where threads are being synced - * @prop {Array} deletedThreads An array of synced threads that the current user no longer has access to. If a thread channel is uncached, it will be an object with an `id` key. No other property is guaranteed - * @prop {Array} activeThreads An array of synced active threads that the current user can access - * @prop {Array} joinedThreadsMember An array of thread member objects where the current user has been added in a synced thread channel - */ + * Fired when the current user gains access to a channel + * @event Client#threadListSync + * @prop {Guild} guild The guild where threads are being synced + * @prop {Array} deletedThreads An array of synced threads that the current user no longer has access to. If a thread channel is uncached, it will be an object with an `id` key. No other property is guaranteed + * @prop {Array} activeThreads An array of synced active threads that the current user can access + * @prop {Array} joinedThreadsMember An array of thread member objects where the current user has been added in a synced thread channel + */ this.emit("threadListSync", guild, deletedThreads, activeThreads, joinedThreadsMember); break; } @@ -2008,13 +2008,13 @@ class Shard extends EventEmitter { } member = channel.members.update(packet.d, this.client); /** - * Fired when a thread member is updated - * @event Client#threadMemberUpdate - * @prop {NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel} channel The channel - * @prop {ThreadMember} member The updated thread member - * @prop {Object} oldMember The old thread member data - * @prop {Number} oldMember.flags User thread settings - */ + * Fired when a thread member is updated + * @event Client#threadMemberUpdate + * @prop {NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel} channel The channel + * @prop {ThreadMember} member The updated thread member + * @prop {Object} oldMember The old thread member data + * @prop {Number} oldMember.flags User thread settings + */ this.emit("threadMemberUpdate", channel, member, oldMember); break; } @@ -2045,12 +2045,12 @@ class Shard extends EventEmitter { }); const removedMembers = packet.d.removed_member_ids?.map((id) => channel.members.remove({id}) || {id}); /** - * Fired when anyone is added or removed from a thread. If the `guildMembers` intent is not specified, this will only apply for the current user - * @event Client#threadMembersUpdate - * @prop {NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel} channel The thread channel - * @prop {Array} addedMembers An array of members that were added to the thread channel - * @prop {Array} removedMembers An array of members that were removed from the thread channel. If a member is uncached, it will be an object with an `id` key. No other property is guaranteed - */ + * Fired when anyone is added or removed from a thread. If the `guildMembers` intent is not specified, this will only apply for the current user + * @event Client#threadMembersUpdate + * @prop {NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel} channel The thread channel + * @prop {Array} addedMembers An array of members that were added to the thread channel + * @prop {Array} removedMembers An array of members that were removed from the thread channel. If a member is uncached, it will be an object with an `id` key. No other property is guaranteed + */ this.emit("threadMembersUpdate", channel, addedMembers || [], removedMembers || []); break; } @@ -2061,10 +2061,10 @@ class Shard extends EventEmitter { break; } /** - * Fired when a stage instance is created - * @event Client#stageInstanceCreate - * @prop {StageInstance} stageInstance The stage instance - */ + * Fired when a stage instance is created + * @event Client#stageInstanceCreate + * @prop {StageInstance} stageInstance The stage instance + */ this.emit("stageInstanceCreate", guild.stageInstances.add(packet.d, this.client)); break; } @@ -2084,14 +2084,14 @@ class Shard extends EventEmitter { }; } /** - * Fired when a stage instance is updated - * @event Client#stageInstanceUpdate - * @prop {StageInstance} stageInstance The stage instance - * @prop {Object?} oldStageInstance The old stage instance. If the stage instance was cached, this will be an object with the properties below. Otherwise, it will be null - * @prop {Boolean} oldStageInstance.discoverableDisabled Whether or not stage discovery was disabled - * @prop {Number} oldStageInstance.privacyLevel The privacy level of the stage instance. 1 is public, 2 is guild only - * @prop {String} oldStageInstance.topic The stage instance topic - */ + * Fired when a stage instance is updated + * @event Client#stageInstanceUpdate + * @prop {StageInstance} stageInstance The stage instance + * @prop {Object?} oldStageInstance The old stage instance. If the stage instance was cached, this will be an object with the properties below. Otherwise, it will be null + * @prop {Boolean} oldStageInstance.discoverableDisabled Whether or not stage discovery was disabled + * @prop {Number} oldStageInstance.privacyLevel The privacy level of the stage instance. 1 is public, 2 is guild only + * @prop {String} oldStageInstance.topic The stage instance topic + */ this.emit("stageInstanceUpdate", guild.stageInstances.update(packet.d, this.client), oldStageInstance); break; } @@ -2102,19 +2102,19 @@ class Shard extends EventEmitter { break; } /** - * Fired when a stage instance is deleted - * @event Client#stageInstanceDelete - * @prop {StageInstance} stageInstance The deleted stage instance - */ + * Fired when a stage instance is deleted + * @event Client#stageInstanceDelete + * @prop {StageInstance} stageInstance The deleted stage instance + */ this.emit("stageInstanceDelete", guild.stageInstances.remove(packet.d) || new StageInstance(packet.d, this.client)); break; } case "GUILD_INTEGRATIONS_UPDATE": { /** - * Fired when a guild integration is updated - * @event Client#guildIntegrationsUpdate - * @prop {Guild} guild The guild where the integration was updated. If the guild isn't cached, this will be an object with an `id` key. No other properties are guaranteed - */ + * Fired when a guild integration is updated + * @event Client#guildIntegrationsUpdate + * @prop {Guild} guild The guild where the integration was updated. If the guild isn't cached, this will be an object with an `id` key. No other properties are guaranteed + */ this.emit("guildIntegrationsUpdate", this.client.guilds.get(packet.d.guild_id) || {id: packet.d.guild_id}); break; } @@ -2126,10 +2126,10 @@ class Shard extends EventEmitter { } /** - * Fired when a guild scheduled event is created - * @event Client#guildScheduledEventCreate - * @prop {GuildScheduledEvent} event The event - */ + * Fired when a guild scheduled event is created + * @event Client#guildScheduledEventCreate + * @prop {GuildScheduledEvent} event The event + */ this.emit("guildScheduledEventCreate", guild.events.add(packet.d, this.client)); break; } @@ -2159,23 +2159,23 @@ class Shard extends EventEmitter { } /** - * Fired when a guild scheduled event is updated - * @event Client#guildScheduledEventUpdate - * @prop {GuildScheduledEvent} event The updated event - * @prop {Object?} oldEvent The old guild event data, or null if the event wasn't cached. - * @prop {(VoiceChannel | StageChannel | Object)?} oldEvent.channel The channel where the event is held - * @prop {String?} oldEvent.description The description of the event - * @prop {String?} oldEvent.entityID The Entity ID associated to the event - * @prop {Object?} oldEvent.entityMetadata Metadata for the event - * @prop {String?} oldEvent.enitityMetadata.location Location of the event - * @prop {Number} oldEvent.entityType The event entity type - * @prop {String?} oldEvent.image The hash of the event's image - * @prop {String} oldEvent.name The name of the event - * @prop {Number} oldEvent.privacyLevel The privacy level of the event - * @prop {Number?} oldEvent.scheduledEndTime The time the event will start - * @prop {Number} oldEvent.scheduledStartTime The time the event will start - * @prop {Number} oldEvent.status The status of the guild scheduled event - */ + * Fired when a guild scheduled event is updated + * @event Client#guildScheduledEventUpdate + * @prop {GuildScheduledEvent} event The updated event + * @prop {Object?} oldEvent The old guild event data, or null if the event wasn't cached. + * @prop {(VoiceChannel | StageChannel | Object)?} oldEvent.channel The channel where the event is held + * @prop {String?} oldEvent.description The description of the event + * @prop {String?} oldEvent.entityID The Entity ID associated to the event + * @prop {Object?} oldEvent.entityMetadata Metadata for the event + * @prop {String?} oldEvent.enitityMetadata.location Location of the event + * @prop {Number} oldEvent.entityType The event entity type + * @prop {String?} oldEvent.image The hash of the event's image + * @prop {String} oldEvent.name The name of the event + * @prop {Number} oldEvent.privacyLevel The privacy level of the event + * @prop {Number?} oldEvent.scheduledEndTime The time the event will start + * @prop {Number} oldEvent.scheduledStartTime The time the event will start + * @prop {Number} oldEvent.status The status of the guild scheduled event + */ this.emit("guildScheduledEventUpdate", guild.events.update(packet.d, this.client), oldEvent); break; } @@ -2186,10 +2186,10 @@ class Shard extends EventEmitter { break; } /** - * Fired when a guild scheduled event is deleted - * @event Client#guildScheduledEventDelete - * @prop {GuildScheduledEvent} event The event that was deleted. - */ + * Fired when a guild scheduled event is deleted + * @event Client#guildScheduledEventDelete + * @prop {GuildScheduledEvent} event The event that was deleted. + */ this.emit("guildScheduledEventDelete", guild.events.remove(packet.d) || new GuildScheduledEvent(packet.d, this.client)); break; } @@ -2208,11 +2208,11 @@ class Shard extends EventEmitter { } /** - * Fired when an user has subscribed to a Guild Event. - * @event Client#guildScheduledEventUserAdd - * @prop {GuildScheduledEvent | Object} event The guild event that the user subscribed to. If the event is uncached, this will be an object with `id` and `guild` keys. No other property is guaranteed - * @prop {User | Object} user The user that subscribed to the Guild Event. If the user is uncached, this will be an object with an `id` key. No other property is guaranteed - */ + * Fired when an user has subscribed to a Guild Event. + * @event Client#guildScheduledEventUserAdd + * @prop {GuildScheduledEvent | Object} event The guild event that the user subscribed to. If the event is uncached, this will be an object with `id` and `guild` keys. No other property is guaranteed + * @prop {User | Object} user The user that subscribed to the Guild Event. If the user is uncached, this will be an object with an `id` key. No other property is guaranteed + */ this.emit("guildScheduledEventUserAdd", event || {id: packet.d.guild_scheduled_event_id, guild: guild}, user); break; } @@ -2231,20 +2231,20 @@ class Shard extends EventEmitter { } /** - * Fired when an user has unsubscribed from a Guild Event. - * @event Client#guildScheduledEventUserRemove - * @prop {GuildScheduledEvent | string} event The guild event that the user unsubscribed to. This will be the guild event ID if the guild was uncached - * @prop {User | string} user The user that unsubscribed to the Guild Event. This will be the user ID if the user was uncached - */ + * Fired when an user has unsubscribed from a Guild Event. + * @event Client#guildScheduledEventUserRemove + * @prop {GuildScheduledEvent | string} event The guild event that the user unsubscribed to. This will be the guild event ID if the guild was uncached + * @prop {User | string} user The user that unsubscribed to the Guild Event. This will be the user ID if the user was uncached + */ this.emit("guildScheduledEventUserRemove", event || {id: packet.d.guild_scheduled_event_id, guild: guild}, user); break; } case "INTERACTION_CREATE": { /** - * Fired when an interaction is created - * @event Client#interactionCreate - * @prop {CommandInteraction | ComponentInteraction | AutocompleteInteraction | ModalSubmitInteraction} interaction The Interaction that was created - */ + * Fired when an interaction is created + * @event Client#interactionCreate + * @prop {CommandInteraction | ComponentInteraction | AutocompleteInteraction | ModalSubmitInteraction} interaction The Interaction that was created + */ this.emit("interactionCreate", Interaction.from(packet.d, this.client)); break; } @@ -2341,12 +2341,12 @@ class Shard extends EventEmitter { } } /** - * Fired when someone votes on a poll. If the poll allows multiple selection, this event will fire for each answer - * @event Client#messagePollVoteAdd - * @prop {Message | Object} message The message object. If the message is not cached, this will be an object with `id` and `channel` keys. If the channel is not cached, channel key will be an object with only an id. No other property is guaranteed - * @prop {Number} answerID The ID of the answer the user voted for - * @prop {User | Object} voter The user that voted. If the user is not cached, this will be an object with an `id` key. No other property is guaranteed - */ + * Fired when someone votes on a poll. If the poll allows multiple selection, this event will fire for each answer + * @event Client#messagePollVoteAdd + * @prop {Message | Object} message The message object. If the message is not cached, this will be an object with `id` and `channel` keys. If the channel is not cached, channel key will be an object with only an id. No other property is guaranteed + * @prop {Number} answerID The ID of the answer the user voted for + * @prop {User | Object} voter The user that voted. If the user is not cached, this will be an object with an `id` key. No other property is guaranteed + */ this.emit("messagePollVoteAdd", message, packet.d.answer_id, user ?? {id: packet.d.user_id}); break; } @@ -2365,22 +2365,22 @@ class Shard extends EventEmitter { } } /** - * Fired when someone removes their vote on a poll. If the poll allows multiple selection, this event will fire for each answer - * @event Client#messagePollVoteRemove - * @prop {Message | Object} message The message object. If the message is not cached, this will be an object with `id` and `channel` keys. If the channel is not cached, channel key will be an object with only an id. No other property is guaranteed - * @prop {Number} answerID The ID of the answer the user voted for - * @prop {User | Object} voter The user that voted. If the user is not cached, this will be an object with an `id` key. No other property is guaranteed - */ + * Fired when someone removes their vote on a poll. If the poll allows multiple selection, this event will fire for each answer + * @event Client#messagePollVoteRemove + * @prop {Message | Object} message The message object. If the message is not cached, this will be an object with `id` and `channel` keys. If the channel is not cached, channel key will be an object with only an id. No other property is guaranteed + * @prop {Number} answerID The ID of the answer the user voted for + * @prop {User | Object} voter The user that voted. If the user is not cached, this will be an object with an `id` key. No other property is guaranteed + */ this.emit("messagePollVoteRemove", message, packet.d.answer_id, user ?? {id: packet.d.user_id}); break; } default: { /** - * Fired when the shard encounters an unknown packet - * @event Client#unknown - * @prop {Object} packet The unknown packet - * @prop {Number} id The ID of the shard - */ + * Fired when the shard encounters an unknown packet + * @event Client#unknown + * @prop {Object} packet The unknown packet + * @prop {Number} id The ID of the shard + */ this.emit("unknown", packet, this.id); break; } @@ -2510,10 +2510,10 @@ class Shard extends EventEmitter { #onWSOpenUnbound() { this.status = "handshaking"; /** - * Fired when the shard establishes a connection - * @event Client#connect - * @prop {Number} id The ID of the shard - */ + * Fired when the shard establishes a connection + * @event Client#connect + * @prop {Number} id The ID of the shard + */ this.emit("connect", this.id); this.lastHeartbeatAck = true; } diff --git a/lib/gateway/ShardManager.js b/lib/gateway/ShardManager.js index c7b28dca..9ac1506b 100644 --- a/lib/gateway/ShardManager.js +++ b/lib/gateway/ShardManager.js @@ -22,6 +22,7 @@ class ShardManager extends Collection { constructor(client, options = {}) { super(Shard); this.#client = client; + /* eslint-disable @stylistic/key-spacing -- this is spaced differently to the rest */ this.options = Object.assign({ autoreconnect: true, compress: false, @@ -38,8 +39,9 @@ class ShardManager extends Collection { maxShards: 1, seedVoiceConnections: false, requestTimeout: 15000, - reconnectDelay: ((lastDelay, attempts) => Math.pow(attempts + 1, 0.7) * 20000) + reconnectDelay: (lastDelay, attempts) => Math.pow(attempts + 1, 0.7) * 20000 }, options); + /* eslint-enable @stylistic/key-spacing */ if(typeof this.options.intents !== "undefined") { // Resolve intents option to the proper integer @@ -83,10 +85,10 @@ class ShardManager extends Collection { shard = this.add(new Shard(id, this.#client)); shard.on("ready", () => { /** - * Fired when a shard turns ready - * @event Client#shardReady - * @prop {Number} id The ID of the shard - */ + * Fired when a shard turns ready + * @event Client#shardReady + * @prop {Number} id The ID of the shard + */ this.#client.emit("shardReady", shard.id); if(this.#client.ready) { return; @@ -99,16 +101,16 @@ class ShardManager extends Collection { this.#client.ready = true; this.#client.startTime = Date.now(); /** - * Fired when all shards turn ready - * @event Client#ready - */ + * Fired when all shards turn ready + * @event Client#ready + */ this.#client.emit("ready"); }).on("resume", () => { /** - * Fired when a shard resumes - * @event Client#shardResume - * @prop {Number} id The ID of the shard - */ + * Fired when a shard resumes + * @event Client#shardResume + * @prop {Number} id The ID of the shard + */ this.#client.emit("shardResume", shard.id); if(this.#client.ready) { return; @@ -123,11 +125,11 @@ class ShardManager extends Collection { this.#client.emit("ready"); }).on("disconnect", (error) => { /** - * Fired when a shard disconnects - * @event Client#shardDisconnect - * @prop {Error?} error The error, if any - * @prop {Number} id The ID of the shard - */ + * Fired when a shard disconnects + * @event Client#shardDisconnect + * @prop {Error?} error The error, if any + * @prop {Number} id The ID of the shard + */ this.#client.emit("shardDisconnect", error, shard.id); for(const other of this.values()) { if(other.ready) { @@ -137,9 +139,9 @@ class ShardManager extends Collection { this.#client.ready = false; this.#client.startTime = 0; /** - * Fired when all shards disconnect - * @event Client#disconnect - */ + * Fired when all shards disconnect + * @event Client#disconnect + */ this.#client.emit("disconnect"); }); } diff --git a/lib/rest/Endpoints.js b/lib/rest/Endpoints.js index 30ca559d..af4ffe40 100644 --- a/lib/rest/Endpoints.js +++ b/lib/rest/Endpoints.js @@ -1,5 +1,7 @@ "use strict"; +/* eslint-disable @stylistic/no-multi-spaces -- currently-aligned manually */ + const {REST_VERSION} = require("../Constants"); module.exports.BASE_URL = "/api/v" + REST_VERSION; diff --git a/lib/rest/RequestHandler.js b/lib/rest/RequestHandler.js index 139f8e40..3ad16f02 100644 --- a/lib/rest/RequestHandler.js +++ b/lib/rest/RequestHandler.js @@ -12,8 +12,8 @@ const SequentialBucket = require("../util/SequentialBucket"); const Zlib = require("node:zlib"); /** -* Handles API requests -*/ + * Handles API requests + */ class RequestHandler { #client; globalBlock = false; @@ -54,17 +54,17 @@ class RequestHandler { } /** - * Make an API request - * @arg {String} method Uppercase HTTP method - * @arg {String} url URL of the endpoint - * @arg {Boolean} [auth] Whether to add the Authorization header and token or not - * @arg {Object} [body] Request payload - * @arg {Object | Array} [file] File object or an array of them - * @arg {Buffer} file.file A buffer containing file data - * @arg {String} file.name What to name the file - * @arg {String} file.fieldName The multipart body field name - * @returns {Promise} Resolves with the returned JSON data - */ + * Make an API request + * @param {String} method Uppercase HTTP method + * @param {String} url URL of the endpoint + * @param {Boolean} [auth] Whether to add the Authorization header and token or not + * @param {Object} [body] Request payload + * @param {Object | Array} [file] File object or an array of them + * @param {Buffer} file.file A buffer containing file data + * @param {String} file.name What to name the file + * @param {String} file.fieldName The multipart body field name + * @returns {Promise} Resolves with the returned JSON data + */ request(method, url, auth, body, file, _route, short) { const route = _route || this.routefy(url, method); @@ -250,12 +250,12 @@ class RequestHandler { if(method !== "GET" && (resp.headers["x-ratelimit-remaining"] == undefined || resp.headers["x-ratelimit-limit"] == undefined) && this.ratelimits[route].limit !== 1) { this.#client.emit("debug", `Missing ratelimit headers for SequentialBucket(${this.ratelimits[route].remaining}/${this.ratelimits[route].limit}) with non-default limit\n` - + `${resp.statusCode} ${resp.statusMessage}: ${method} ${route} | ${resp.headers["cf-ray"]}\n` - + "content-type = " + resp.headers["content-type"] + "\n" - + "x-ratelimit-remaining = " + resp.headers["x-ratelimit-remaining"] + "\n" - + "x-ratelimit-limit = " + resp.headers["x-ratelimit-limit"] + "\n" - + "x-ratelimit-reset = " + resp.headers["x-ratelimit-reset"] + "\n" - + "x-ratelimit-global = " + resp.headers["x-ratelimit-global"]); + + `${resp.statusCode} ${resp.statusMessage}: ${method} ${route} | ${resp.headers["cf-ray"]}\n` + + "content-type = " + resp.headers["content-type"] + "\n" + + "x-ratelimit-remaining = " + resp.headers["x-ratelimit-remaining"] + "\n" + + "x-ratelimit-limit = " + resp.headers["x-ratelimit-limit"] + "\n" + + "x-ratelimit-reset = " + resp.headers["x-ratelimit-reset"] + "\n" + + "x-ratelimit-global = " + resp.headers["x-ratelimit-global"]); } this.ratelimits[route].remaining = resp.headers["x-ratelimit-remaining"] === undefined ? 1 : +resp.headers["x-ratelimit-remaining"] || 0; diff --git a/lib/structures/ApplicationCommand.js b/lib/structures/ApplicationCommand.js index 3a76b2e3..8b8f7495 100644 --- a/lib/structures/ApplicationCommand.js +++ b/lib/structures/ApplicationCommand.js @@ -16,7 +16,6 @@ class ApplicationCommand extends Base { super(data.id); this.#client = client; - /** * The ID of the application that this command belongs to * @type {String} @@ -109,17 +108,17 @@ class ApplicationCommand extends Base { } /** - * Edit this application command - * @arg {Object} options The properties to edit - * @arg {String} [options.name] The command name - * @arg {Object} [options.nameLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to names for that locale - * @arg {String} [options.description] The command description (chat input commands only) - * @arg {Object} [options.descriptionLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to descriptions for that locale - * @arg {Array} [options.options] An array of [command options](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure) - * @arg {String} [options.defaultMemberPermissions] The [permissions](https://discord.com/developers/docs/topics/permissions) required by default for this command to be usable - * @arg {Boolean} [options.dmPermission] If this command can be used in direct messages (global commands only) - * @returns {Promise} - */ + * Edit this application command + * @param {Object} options The properties to edit + * @param {String} [options.name] The command name + * @param {Object} [options.nameLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to names for that locale + * @param {String} [options.description] The command description (chat input commands only) + * @param {Object} [options.descriptionLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to descriptions for that locale + * @param {Array} [options.options] An array of [command options](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure) + * @param {String} [options.defaultMemberPermissions] The [permissions](https://discord.com/developers/docs/topics/permissions) required by default for this command to be usable + * @param {Boolean} [options.dmPermission] If this command can be used in direct messages (global commands only) + * @returns {Promise} + */ edit(options) { return this.guildID === undefined ? this.#client.editCommand.call(this.#client, this.id, options) : this.#client.editGuildCommand.call(this.#client, this.id, this.guildID, options); } diff --git a/lib/structures/AutoModerationRule.js b/lib/structures/AutoModerationRule.js index b6700af2..2aabd740 100644 --- a/lib/structures/AutoModerationRule.js +++ b/lib/structures/AutoModerationRule.js @@ -80,15 +80,15 @@ class AutoModerationRule extends Base { /** * Edits this auto moderation rule - * @arg {Object} options The new rule options - * @arg {Object[]} [options.actions] The [actions](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object) done when the rule is violated - * @arg {Boolean} [options.enabled=false] If the rule is enabled, false by default - * @arg {Number} [options.eventType] The [event type](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-event-types) for the rule - * @arg {String[]} [options.exemptChannels] Any channels where this rule does not apply - * @arg {String[]} [options.exemptRoles] Any roles to which this rule does not apply - * @arg {String} [options.name] The name of the rule - * @arg {String} [options.reason] The reason to be displayed in audit logs - * @arg {Object} [options.triggerMetadata] The [trigger metadata](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-metadata) for the rule + * @param {Object} options The new rule options + * @param {Object[]} [options.actions] The [actions](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object) done when the rule is violated + * @param {Boolean} [options.enabled=false] If the rule is enabled, false by default + * @param {Number} [options.eventType] The [event type](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-event-types) for the rule + * @param {String[]} [options.exemptChannels] Any channels where this rule does not apply + * @param {String[]} [options.exemptRoles] Any roles to which this rule does not apply + * @param {String} [options.name] The name of the rule + * @param {String} [options.reason] The reason to be displayed in audit logs + * @param {Object} [options.triggerMetadata] The [trigger metadata](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-metadata) for the rule * @returns {Promise} */ edit(options) { diff --git a/lib/structures/AutocompleteInteraction.js b/lib/structures/AutocompleteInteraction.js index dc2e49fd..a506ca53 100644 --- a/lib/structures/AutocompleteInteraction.js +++ b/lib/structures/AutocompleteInteraction.js @@ -4,9 +4,9 @@ const Interaction = require("./Interaction"); const {InteractionResponseTypes} = require("../Constants"); /** -* Represents an application command autocomplete interaction. See Interaction for more properties. -* @extends Interaction -*/ + * Represents an application command autocomplete interaction. See Interaction for more properties. + * @extends Interaction + */ class AutocompleteInteraction extends Interaction { /** * @override @@ -24,25 +24,25 @@ class AutocompleteInteraction extends Interaction { } /** - * Acknowledges the autocomplete interaction with a result of choices - * Note: You can **not** use more than 1 initial interaction response per interaction - * @arg {Array} choices The autocomplete choices to return to the user - * @arg {String | Number} choices[].name The choice display name - * @arg {String} choices[].value The choice value to return to the bot - * @returns {Promise} - */ + * Acknowledges the autocomplete interaction with a result of choices + * Note: You can **not** use more than 1 initial interaction response per interaction + * @param {Array} choices The autocomplete choices to return to the user + * @param {String | Number} choices[].name The choice display name + * @param {String} choices[].value The choice value to return to the bot + * @returns {Promise} + */ acknowledge(choices) { return this.result(choices); } /** - * Acknowledges the autocomplete interaction with a result of choices - * Note: You can **not** use more than 1 initial interaction response per interaction. - * @arg {Array} choices The autocomplete choices to return to the user - * @arg {String | Number} choices[].name The choice display name - * @arg {String} choices[].value The choice value to return to the bot - * @returns {Promise} - */ + * Acknowledges the autocomplete interaction with a result of choices + * Note: You can **not** use more than 1 initial interaction response per interaction. + * @param {Array} choices The autocomplete choices to return to the user + * @param {String | Number} choices[].name The choice display name + * @param {String} choices[].value The choice value to return to the bot + * @returns {Promise} + */ result(choices) { if(this.acknowledged === true) { throw new Error("You have already acknowledged this interaction."); diff --git a/lib/structures/Base.js b/lib/structures/Base.js index d2ddfefc..14b1f100 100644 --- a/lib/structures/Base.js +++ b/lib/structures/Base.js @@ -35,8 +35,8 @@ class Base { /** * Gets the number of milliseconds since epoch represented by an ID/snowflake - * @param {string} id The ID of a structure - * @returns {number} + * @param {String} id The ID of a structure + * @returns {Number} */ static getDiscordEpoch(id) { return Math.floor(id / 4194304); @@ -68,7 +68,7 @@ class Base { const type = typeof value; if(value === undefined) { continue; - } else if(type !== "object" && type !== "function" && type !== "bigint" || value === null) { + } else if((type !== "object" && type !== "function" && type !== "bigint") || value === null) { json[prop] = value; } else if(value.toJSON !== undefined) { json[prop] = value.toJSON(); diff --git a/lib/structures/CategoryChannel.js b/lib/structures/CategoryChannel.js index 8b6f0b73..89c24819 100644 --- a/lib/structures/CategoryChannel.js +++ b/lib/structures/CategoryChannel.js @@ -5,9 +5,9 @@ const GuildChannel = require("./GuildChannel"); const PermissionOverwrite = require("./PermissionOverwrite"); /** -* Represents a guild category channel. See GuildChannel for more properties and methods. -* @extends GuildChannel -*/ + * Represents a guild category channel. See GuildChannel for more properties and methods. + * @extends GuildChannel + */ class CategoryChannel extends GuildChannel { constructor(data, client) { super(data, client); diff --git a/lib/structures/Channel.js b/lib/structures/Channel.js index 3c20d162..758cad1f 100644 --- a/lib/structures/Channel.js +++ b/lib/structures/Channel.js @@ -5,8 +5,8 @@ const {ChannelTypes} = require("../Constants"); const emitDeprecation = require("../util/emitDeprecation"); /** -* Represents a channel. You also probably want to look at CategoryChannel, NewsChannel, PrivateChannel, TextChannel, and TextVoiceChannel. -*/ + * Represents a channel. You also probably want to look at CategoryChannel, NewsChannel, PrivateChannel, TextChannel, and TextVoiceChannel. + */ class Channel extends Base { /** * The ID of the channel diff --git a/lib/structures/CommandInteraction.js b/lib/structures/CommandInteraction.js index 96ebe551..3db1f12d 100644 --- a/lib/structures/CommandInteraction.js +++ b/lib/structures/CommandInteraction.js @@ -12,9 +12,9 @@ const Collection = require("../util/Collection"); const {InteractionResponseTypes} = require("../Constants"); /** -* Represents an application command interaction. -* @extends Interaction -*/ + * Represents an application command interaction. + * @extends Interaction + */ class CommandInteraction extends Interaction { /** * @override @@ -31,7 +31,7 @@ class CommandInteraction extends Interaction { this.#client = client; if(data.data.resolved !== undefined) { - //Users + // Users if(data.data.resolved.users !== undefined) { const usermap = new Collection(User); Object.entries(data.data.resolved.users).forEach(([id, user]) => { @@ -39,7 +39,7 @@ class CommandInteraction extends Interaction { }); this.data.resolved.users = usermap; } - //Members + // Members if(data.data.resolved.members !== undefined) { const membermap = new Collection(Member); Object.entries(data.data.resolved.members).forEach(([id, member]) => { @@ -54,7 +54,7 @@ class CommandInteraction extends Interaction { }); this.data.resolved.members = membermap; } - //Roles + // Roles if(data.data.resolved.roles !== undefined) { const rolemap = new Collection(Role); Object.entries(data.data.resolved.roles).forEach(([id, role]) => { @@ -62,7 +62,7 @@ class CommandInteraction extends Interaction { }); this.data.resolved.roles = rolemap; } - //Channels + // Channels if(data.data.resolved.channels !== undefined) { const channelmap = new Collection(Channel); Object.entries(data.data.resolved.channels).forEach(([id, channel]) => { @@ -70,7 +70,7 @@ class CommandInteraction extends Interaction { }); this.data.resolved.channels = channelmap; } - //Messages + // Messages if(data.data.resolved.messages !== undefined) { const messagemap = new Collection(Message); Object.entries(data.data.resolved.messages).forEach(([id, message]) => { @@ -78,7 +78,7 @@ class CommandInteraction extends Interaction { }); this.data.resolved.messages = messagemap; } - //Attachments + // Attachments if(data.data.resolved.attachments !== undefined) { const attachmentsmap = new Collection(Attachment); Object.entries(data.data.resolved.attachments).forEach(([id, attachment]) => { @@ -90,34 +90,34 @@ class CommandInteraction extends Interaction { } /** - * Acknowledges the interaction with a defer response - * Note: You can **not** use more than 1 initial interaction response per interaction. - * @arg {Number} [flags] A number representing the flags to apply. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list - * @returns {Promise} - */ + * Acknowledges the interaction with a defer response + * Note: You can **not** use more than 1 initial interaction response per interaction. + * @param {Number} [flags] A number representing the flags to apply. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list + * @returns {Promise} + */ acknowledge(flags) { return this.defer(flags); } /** - * Respond to the interaction with a followup message - * @arg {String | Object} content A string or object. If an object is passed: - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {Buffer} content.attachments[].file A buffer containing file data - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Array} [options.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {Number} [content.flags] A number representing the flags to apply. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list - * @arg {Object} [content.poll] A poll object. See [Discord's Documentation](https://discord.com/developers/docs/resources/poll#poll-create-request-object-poll-create-request-object-structure) for object structure - * @arg {Boolean} [content.tts] Set the message TTS flag - * @returns {Promise} - */ + * Respond to the interaction with a followup message + * @param {String | Object} content A string or object. If an object is passed: + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. + * @param {Array} [content.attachments] The files to attach to the message + * @param {Buffer} content.attachments[].file A buffer containing file data + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Array} [options.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {Number} [content.flags] A number representing the flags to apply. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list + * @param {Object} [content.poll] A poll object. See [Discord's Documentation](https://discord.com/developers/docs/resources/poll#poll-create-request-object-poll-create-request-object-structure) for object structure + * @param {Boolean} [content.tts] Set the message TTS flag + * @returns {Promise} + */ createFollowup(content) { if(this.acknowledged === false) { throw new Error("createFollowup cannot be used to acknowledge an interaction, please use acknowledge, createMessage, or defer first."); @@ -135,24 +135,24 @@ class CommandInteraction extends Interaction { } /** - * Acknowledges the interaction with a message. If already acknowledged runs createFollowup - * @arg {String | Object} content A string or object. If an object is passed: - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {Buffer} content.attachments[].file A buffer containing file data - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {Number} [content.flags] A number representing the flags to apply. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list - * @arg {Object} [content.poll] A poll object. See [Discord's Documentation](https://discord.com/developers/docs/resources/poll#poll-create-request-object-poll-create-request-object-structure) for object structure - * @arg {Boolean} [content.tts] Set the message TTS flag - * @returns {Promise} - */ + * Acknowledges the interaction with a message. If already acknowledged runs createFollowup + * @param {String | Object} content A string or object. If an object is passed: + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. + * @param {Array} [content.attachments] The files to attach to the message + * @param {Buffer} content.attachments[].file A buffer containing file data + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {Number} [content.flags] A number representing the flags to apply. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list + * @param {Object} [content.poll] A poll object. See [Discord's Documentation](https://discord.com/developers/docs/resources/poll#poll-create-request-object-poll-create-request-object-structure) for object structure + * @param {Boolean} [content.tts] Set the message TTS flag + * @returns {Promise} + */ createMessage(content) { if(this.acknowledged === true) { return this.createFollowup(content); @@ -180,13 +180,13 @@ class CommandInteraction extends Interaction { } /** - * Responds to an interaction with a modal - * @arg {Object} content An object - * @arg {String} [content.title] The title for the modal, max 45 characters - * @arg {String} [content.custom_id] The custom identifier for the modal - * @arg {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @returns {Promise} - */ + * Responds to an interaction with a modal + * @param {Object} content An object + * @param {String} [content.title] The title for the modal, max 45 characters + * @param {String} [content.custom_id] The custom identifier for the modal + * @param {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @returns {Promise} + */ async createModal(content) { return this.#client.createInteractionResponse.call(this.#client, this.id, this.token, { type: InteractionResponseTypes.MODAL, @@ -195,11 +195,11 @@ class CommandInteraction extends Interaction { } /** - * Acknowledges the interaction with a defer response - * Note: You can **not** use more than 1 initial interaction response per interaction. - * @arg {Number} [flags] A number representing the flags to apply. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list - * @returns {Promise} - */ + * Acknowledges the interaction with a defer response + * Note: You can **not** use more than 1 initial interaction response per interaction. + * @param {Number} [flags] A number representing the flags to apply. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list + * @returns {Promise} + */ defer(flags) { if(this.acknowledged === true) { throw new Error("You have already acknowledged this interaction."); @@ -213,10 +213,10 @@ class CommandInteraction extends Interaction { } /** - * Delete a message - * @arg {String} messageID the id of the message to delete, or "@original" for the original response - * @returns {Promise} - */ + * Delete a message + * @param {String} messageID the id of the message to delete, or "@original" for the original response + * @returns {Promise} + */ deleteMessage(messageID) { if(this.acknowledged === false) { throw new Error("deleteMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, or defer first."); @@ -225,10 +225,10 @@ class CommandInteraction extends Interaction { } /** - * Delete the Original message - * Warning: Will error with ephemeral messages - * @returns {Promise} - */ + * Delete the Original message + * Warning: Will error with ephemeral messages + * @returns {Promise} + */ deleteOriginalMessage() { if(this.acknowledged === false) { throw new Error("deleteOriginalMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, or defer first."); @@ -237,24 +237,24 @@ class CommandInteraction extends Interaction { } /** - * Edit a message - * @arg {String} messageID the id of the message to edit, or "@original" for the original response - * @arg {Object} content Interaction message edit options - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. - * @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) - * @arg {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @returns {Promise} - */ + * Edit a message + * @param {String} messageID the id of the message to edit, or "@original" for the original response + * @param {Object} content Interaction message edit options + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. + * @param {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. + * @param {Array} [content.attachments] The files to attach to the message + * @param {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) + * @param {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @returns {Promise} + */ editMessage(messageID, content) { if(this.acknowledged === false) { throw new Error("editMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, or defer first."); @@ -272,23 +272,23 @@ class CommandInteraction extends Interaction { } /** - * Edit the Original response message - * @arg {Object} content Interaction message edit options - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. - * @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) - * @arg {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @returns {Promise} - */ + * Edit the Original response message + * @param {Object} content Interaction message edit options + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. + * @param {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. + * @param {Array} [content.attachments] The files to attach to the message + * @param {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) + * @param {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @returns {Promise} + */ editOriginalMessage(content) { if(this.acknowledged === false) { throw new Error("editOriginalMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, or defer first."); @@ -306,17 +306,16 @@ class CommandInteraction extends Interaction { } /** - * Get the Original response message - * Warning: Will error with ephemeral messages - * @returns {Promise} - */ + * Get the Original response message + * Warning: Will error with ephemeral messages + * @returns {Promise} + */ getOriginalMessage() { if(this.acknowledged === false) { throw new Error("getOriginalMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, or defer first."); } return this.#client.getWebhookMessage.call(this.#client, this.applicationID, this.token, "@original"); } - } module.exports = CommandInteraction; diff --git a/lib/structures/ComponentInteraction.js b/lib/structures/ComponentInteraction.js index d1dd0cf7..3eba3323 100644 --- a/lib/structures/ComponentInteraction.js +++ b/lib/structures/ComponentInteraction.js @@ -11,9 +11,9 @@ const Collection = require("../util/Collection"); const {InteractionResponseTypes} = require("../Constants"); /** -* Represents a message component interaction. -* @extends Interaction -*/ + * Represents a message component interaction. + * @extends Interaction + */ class ComponentInteraction extends Interaction { /** * @override @@ -30,7 +30,7 @@ class ComponentInteraction extends Interaction { this.#client = client; if(data.data.resolved !== undefined) { - //Users + // Users if(data.data.resolved.users !== undefined) { const usermap = new Collection(User); Object.entries(data.data.resolved.users).forEach(([id, user]) => { @@ -38,7 +38,7 @@ class ComponentInteraction extends Interaction { }); this.data.resolved.users = usermap; } - //Members + // Members if(data.data.resolved.members !== undefined) { const membermap = new Collection(Member); Object.entries(data.data.resolved.members).forEach(([id, member]) => { @@ -53,7 +53,7 @@ class ComponentInteraction extends Interaction { }); this.data.resolved.members = membermap; } - //Roles + // Roles if(data.data.resolved.roles !== undefined) { const rolemap = new Collection(Role); Object.entries(data.data.resolved.roles).forEach(([id, role]) => { @@ -61,7 +61,7 @@ class ComponentInteraction extends Interaction { }); this.data.resolved.roles = rolemap; } - //Channels + // Channels if(data.data.resolved.channels !== undefined) { const channelmap = new Collection(Channel); Object.entries(data.data.resolved.channels).forEach(([id, channel]) => { @@ -81,32 +81,32 @@ class ComponentInteraction extends Interaction { } /** - * Acknowledges the interaction with a defer message update response - * @returns {Promise} - */ + * Acknowledges the interaction with a defer message update response + * @returns {Promise} + */ acknowledge() { return this.deferUpdate(); } /** - * Respond to the interaction with a followup message - * @arg {String | Object} content A string or object. If an object is passed: - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {Buffer} content.attachments[].file A buffer containing file data - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Array} [options.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {Number} [content.flags] A number representing the flags to apply. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list - * @arg {Object} [content.poll] A poll object. See [Discord's Documentation](https://discord.com/developers/docs/resources/poll#poll-create-request-object-poll-create-request-object-structure) for object structure - * @arg {Boolean} [content.tts] Set the message TTS flag - * @returns {Promise} - */ + * Respond to the interaction with a followup message + * @param {String | Object} content A string or object. If an object is passed: + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. + * @param {Array} [content.attachments] The files to attach to the message + * @param {Buffer} content.attachments[].file A buffer containing file data + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Array} [options.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {Number} [content.flags] A number representing the flags to apply. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list + * @param {Object} [content.poll] A poll object. See [Discord's Documentation](https://discord.com/developers/docs/resources/poll#poll-create-request-object-poll-create-request-object-structure) for object structure + * @param {Boolean} [content.tts] Set the message TTS flag + * @returns {Promise} + */ createFollowup(content) { if(this.acknowledged === false) { throw new Error("createFollowup cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, or editParent first."); @@ -124,24 +124,24 @@ class ComponentInteraction extends Interaction { } /** - * Acknowledges the interaction with a message. If already acknowledged runs createFollowup - * @arg {String | Object} content A string or object. If an object is passed: - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {Buffer} content.attachments[].file A buffer containing file data - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {Number} [content.flags] A number representing the flags to apply. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list - * @arg {Object} [content.poll] A poll object. See [Discord's Documentation](https://discord.com/developers/docs/resources/poll#poll-create-request-object-poll-create-request-object-structure) for object structure - * @arg {Boolean} [content.tts] Set the message TTS flag - * @returns {Promise} - */ + * Acknowledges the interaction with a message. If already acknowledged runs createFollowup + * @param {String | Object} content A string or object. If an object is passed: + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. + * @param {Array} [content.attachments] The files to attach to the message + * @param {Buffer} content.attachments[].file A buffer containing file data + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {Number} [content.flags] A number representing the flags to apply. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list + * @param {Object} [content.poll] A poll object. See [Discord's Documentation](https://discord.com/developers/docs/resources/poll#poll-create-request-object-poll-create-request-object-structure) for object structure + * @param {Boolean} [content.tts] Set the message TTS flag + * @returns {Promise} + */ createMessage(content) { if(this.acknowledged === true) { return this.createFollowup(content); @@ -169,13 +169,13 @@ class ComponentInteraction extends Interaction { } /** - * Responds to an interaction with a modal - * @arg {Object} content An object - * @arg {String} [content.title] The title for the modal, max 45 characters - * @arg {String} [content.custom_id] The custom identifier for the modal - * @arg {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @returns {Promise} - */ + * Responds to an interaction with a modal + * @param {Object} content An object + * @param {String} [content.title] The title for the modal, max 45 characters + * @param {String} [content.custom_id] The custom identifier for the modal + * @param {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @returns {Promise} + */ async createModal(content) { return this.#client.createInteractionResponse.call(this.#client, this.id, this.token, { type: InteractionResponseTypes.MODAL, @@ -184,11 +184,11 @@ class ComponentInteraction extends Interaction { } /** - * Acknowledges the interaction with a defer response - * Note: You can **not** use more than 1 initial interaction response per interaction. - * @arg {Number} [flags] A number representing the flags to apply. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list - * @returns {Promise} - */ + * Acknowledges the interaction with a defer response + * Note: You can **not** use more than 1 initial interaction response per interaction. + * @param {Number} [flags] A number representing the flags to apply. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list + * @returns {Promise} + */ defer(flags) { if(this.acknowledged === true) { throw new Error("You have already acknowledged this interaction."); @@ -202,10 +202,10 @@ class ComponentInteraction extends Interaction { } /** - * Acknowledges the interaction with a defer message update response - * Note: You can **not** use more than 1 initial interaction response per interaction - * @returns {Promise} - */ + * Acknowledges the interaction with a defer message update response + * Note: You can **not** use more than 1 initial interaction response per interaction + * @returns {Promise} + */ deferUpdate() { if(this.acknowledged === true) { throw new Error("You have already acknowledged this interaction."); @@ -216,10 +216,10 @@ class ComponentInteraction extends Interaction { } /** - * Delete a message - * @arg {String} messageID the id of the message to delete, or "@original" for the original response - * @returns {Promise} - */ + * Delete a message + * @param {String} messageID the id of the message to delete, or "@original" for the original response + * @returns {Promise} + */ deleteMessage(messageID) { if(this.acknowledged === false) { throw new Error("deleteMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, or editParent first."); @@ -228,10 +228,10 @@ class ComponentInteraction extends Interaction { } /** - * Delete the parent message - * Warning: Will error with ephemeral messages. - * @returns {Promise} - */ + * Delete the parent message + * Warning: Will error with ephemeral messages. + * @returns {Promise} + */ deleteOriginalMessage() { if(this.acknowledged === false) { throw new Error("deleteOriginalMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, or editParent first."); @@ -240,24 +240,24 @@ class ComponentInteraction extends Interaction { } /** - * Edit a message - * @arg {String} messageID the id of the message to edit, or "@original" for the original response - * @arg {Object} content Interaction message edit options - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. - * @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) - * @arg {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @returns {Promise} - */ + * Edit a message + * @param {String} messageID the id of the message to edit, or "@original" for the original response + * @param {Object} content Interaction message edit options + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. + * @param {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. + * @param {Array} [content.attachments] The files to attach to the message + * @param {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) + * @param {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @returns {Promise} + */ editMessage(messageID, content) { if(this.acknowledged === false) { throw new Error("editMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, or editParent first."); @@ -275,23 +275,23 @@ class ComponentInteraction extends Interaction { } /** - * Edit the parent message - * @arg {Object} content Interaction message edit options - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. - * @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) - * @arg {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @returns {Promise} - */ + * Edit the parent message + * @param {Object} content Interaction message edit options + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. + * @param {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. + * @param {Array} [content.attachments] The files to attach to the message + * @param {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) + * @param {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @returns {Promise} + */ editOriginalMessage(content) { if(this.acknowledged === false) { throw new Error("editOriginalMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, or editParent first."); @@ -309,27 +309,27 @@ class ComponentInteraction extends Interaction { } /** - * Acknowledges the interaction by editing the parent message. If already acknowledged runs editOriginalMessage - * Note: You can **not** use more than 1 initial interaction response per interaction, use edit if you have already responded with a different interaction response - * Warning: Will error with ephemeral messages. - * @arg {String | Object} content What to edit the message with - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here - * @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) - * @arg {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {Number} [content.flags] A number representing the flags to apply. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list - * @arg {Boolean} [content.tts] Set the message TTS flag - * @returns {Promise} - */ + * Acknowledges the interaction by editing the parent message. If already acknowledged runs editOriginalMessage + * Note: You can **not** use more than 1 initial interaction response per interaction, use edit if you have already responded with a different interaction response + * Warning: Will error with ephemeral messages. + * @param {String | Object} content What to edit the message with + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here + * @param {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. + * @param {Array} [content.attachments] The files to attach to the message + * @param {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) + * @param {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {Number} [content.flags] A number representing the flags to apply. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list + * @param {Boolean} [content.tts] Set the message TTS flag + * @returns {Promise} + */ editParent(content) { if(this.acknowledged === true) { return this.editOriginalMessage(content); @@ -357,17 +357,16 @@ class ComponentInteraction extends Interaction { } /** - * Get the parent message - * Warning: Will error with ephemeral messages - * @returns {Promise} - */ + * Get the parent message + * Warning: Will error with ephemeral messages + * @returns {Promise} + */ getOriginalMessage() { if(this.acknowledged === false) { throw new Error("getOriginalMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, or editParent first."); } return this.#client.getWebhookMessage.call(this.#client, this.applicationID, this.token, "@original"); } - } module.exports = ComponentInteraction; diff --git a/lib/structures/ExtendedUser.js b/lib/structures/ExtendedUser.js index c4cfa772..7bec6f2a 100644 --- a/lib/structures/ExtendedUser.js +++ b/lib/structures/ExtendedUser.js @@ -3,9 +3,9 @@ const User = require("./User"); /** -* Represents an extended user -* @extends User -*/ + * Represents an extended user + * @extends User + */ class ExtendedUser extends User { constructor(data, client) { super(data, client); diff --git a/lib/structures/ForumChannel.js b/lib/structures/ForumChannel.js index ee84449e..3e8911ae 100644 --- a/lib/structures/ForumChannel.js +++ b/lib/structures/ForumChannel.js @@ -5,9 +5,9 @@ const GuildChannel = require("./GuildChannel"); const PermissionOverwrite = require("./PermissionOverwrite"); /** -* Represents a guild forum channel. -* @extends GuildChannel -*/ + * Represents a guild forum channel. + * @extends GuildChannel + */ class ForumChannel extends GuildChannel { #client; constructor(data, client) { @@ -116,81 +116,81 @@ class ForumChannel extends GuildChannel { } /** - * Create an invite for the channel - * @arg {Object} [options] Invite generation options - * @arg {Number} [options.maxAge] How long the invite should last in seconds - * @arg {Number} [options.maxUses] How many uses the invite should last for - * @arg {Boolean} [options.temporary] Whether the invite grants temporary membership or not - * @arg {Boolean} [options.unique] Whether the invite is unique or not - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Create an invite for the channel + * @param {Object} [options] Invite generation options + * @param {Number} [options.maxAge] How long the invite should last in seconds + * @param {Number} [options.maxUses] How many uses the invite should last for + * @param {Boolean} [options.temporary] Whether the invite grants temporary membership or not + * @param {Boolean} [options.unique] Whether the invite is unique or not + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ createInvite(options, reason) { return this.#client.createChannelInvite.call(this.#client, this.id, options, reason); } /** - * Create a thread in this channel - * @arg {Object} options The thread options - * @arg {Number} [options.autoArchiveDuration] Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080 - * @arg {Array} [options.appliedTags] The tags to apply to the thread - * @arg {String} options.name The thread channel name - * @arg {Object} options.message The message to attach to the thread (set only if creating a thread in a thread-only channel) - * @arg {Object} [options.message.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [options.message.allowedMentions.everyone] Whether or not to allow @everyone/@here. - * @arg {Boolean | Array} [options.message.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. - * @arg {Boolean | Array} [options.message.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. - * @arg {Array} [options.message.attachments] The files to attach to the message - * @arg {Buffer} options.message.attachments[].file A buffer containing file data - * @arg {String} options.message.attachments[].filename What to name the file - * @arg {String} [options.message.attachments[].description] A description for the attachment - * @arg {Array} [options.message.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [options.message.content] A content string - * @arg {Array} [options.message.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {Array} [options.message.stickerIDs] An array of IDs corresponding to stickers to send - * @arg {Number} [options.rateLimitPerUser] The ratelimit of the channel, in seconds. 0 means no ratelimit is enabled - * @returns {Promise} - */ + * Create a thread in this channel + * @param {Object} options The thread options + * @param {Number} [options.autoArchiveDuration] Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080 + * @param {Array} [options.appliedTags] The tags to apply to the thread + * @param {String} options.name The thread channel name + * @param {Object} options.message The message to attach to the thread (set only if creating a thread in a thread-only channel) + * @param {Object} [options.message.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [options.message.allowedMentions.everyone] Whether or not to allow @everyone/@here. + * @param {Boolean | Array} [options.message.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. + * @param {Boolean | Array} [options.message.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. + * @param {Array} [options.message.attachments] The files to attach to the message + * @param {Buffer} options.message.attachments[].file A buffer containing file data + * @param {String} options.message.attachments[].filename What to name the file + * @param {String} [options.message.attachments[].description] A description for the attachment + * @param {Array} [options.message.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [options.message.content] A content string + * @param {Array} [options.message.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {Array} [options.message.stickerIDs] An array of IDs corresponding to stickers to send + * @param {Number} [options.rateLimitPerUser] The ratelimit of the channel, in seconds. 0 means no ratelimit is enabled + * @returns {Promise} + */ createThread(options) { return this.#client.createThread.call(this.#client, this.id, options); } /** - * Create a channel webhook - * @arg {Object} options Webhook options - * @arg {String?} [options.avatar] The default avatar as a base64 data URI. Note: base64 strings alone are not base64 data URI strings - * @arg {String} options.name The default name - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} Resolves with a webhook object - */ + * Create a channel webhook + * @param {Object} options Webhook options + * @param {String?} [options.avatar] The default avatar as a base64 data URI. Note: base64 strings alone are not base64 data URI strings + * @param {String} options.name The default name + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} Resolves with a webhook object + */ createWebhook(options, reason) { return this.#client.createChannelWebhook.call(this.#client, this.id, options, reason); } /** - * Get all archived threads in this channel - * @arg {String} type The type of thread channel - for forum channels, only "public" is available - * @arg {Object} [options] Additional options when requesting archived threads - * @arg {Date} [options.before] List of threads to return before the timestamp - * @arg {Number} [options.limit] Maximum number of threads to return - * @returns {Promise} An object containing an array of `threads`, an array of `members` and whether the response `hasMore` threads that could be returned in a subsequent call - */ + * Get all archived threads in this channel + * @param {String} type The type of thread channel - for forum channels, only "public" is available + * @param {Object} [options] Additional options when requesting archived threads + * @param {Date} [options.before] List of threads to return before the timestamp + * @param {Number} [options.limit] Maximum number of threads to return + * @returns {Promise} An object containing an array of `threads`, an array of `members` and whether the response `hasMore` threads that could be returned in a subsequent call + */ getArchivedThreads(type, options) { return this.#client.getArchivedThreads.call(this.#client, this.id, type, options); } /** - * Get all invites in the channel - * @returns {Promise>} - */ + * Get all invites in the channel + * @returns {Promise>} + */ getInvites() { return this.#client.getChannelInvites.call(this.#client, this.id); } /** - * Get all the webhooks in the channel - * @returns {Promise>} Resolves with an array of webhook objects - */ + * Get all the webhooks in the channel + * @returns {Promise>} Resolves with an array of webhook objects + */ getWebhooks() { return this.#client.getChannelWebhooks.call(this.#client, this.id); } diff --git a/lib/structures/Guild.js b/lib/structures/Guild.js index 3a32ddff..dfe4bcf1 100644 --- a/lib/structures/Guild.js +++ b/lib/structures/Guild.js @@ -15,9 +15,9 @@ const StageInstance = require("./StageInstance"); const ThreadChannel = require("./ThreadChannel"); /** -* Represents a guild -* @extends Base -*/ + * Represents a guild + * @extends Base + */ class Guild extends Base { #client; /** @@ -486,45 +486,45 @@ class Guild extends Base { /** * Add a user to the guild - * @arg {String} userID The ID of the user - * @arg {String} accessToken The access token of the user - * @arg {Object} [options] Options for adding the user - * @arg {String} [options.nick] The user's nickname - * @arg {Array} [options.roles] Array of role IDs to add to the user - * @arg {Boolean} [options.mute] Whether the user should be muted - * @arg {Boolean} [options.deaf] Whether the user should be deafened + * @param {String} userID The ID of the user + * @param {String} accessToken The access token of the user + * @param {Object} [options] Options for adding the user + * @param {String} [options.nick] The user's nickname + * @param {Array} [options.roles] Array of role IDs to add to the user + * @param {Boolean} [options.mute] Whether the user should be muted + * @param {Boolean} [options.deaf] Whether the user should be deafened */ addMember(userID, accessToken, options = {}) { return this.#client.addGuildMember.call(this.#client, this.id, userID, accessToken, options); } /** - * Add a role to a guild member - * @arg {String} memberID The ID of the member - * @arg {String} roleID The ID of the role - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Add a role to a guild member + * @param {String} memberID The ID of the member + * @param {String} roleID The ID of the role + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ addMemberRole(memberID, roleID, reason) { return this.#client.addGuildMemberRole.call(this.#client, this.id, memberID, roleID, reason); } /** - * Ban a user from the guild - * @arg {String} userID The ID of the member - * @arg {Number} [options.deleteMessageSeconds=0] Number of seconds to delete messages for, between 0 and 604,800 inclusive - * @arg {String} [options.reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Ban a user from the guild + * @param {String} userID The ID of the member + * @param {Number} [options.deleteMessageSeconds=0] Number of seconds to delete messages for, between 0 and 604,800 inclusive + * @param {String} [options.reason] The reason to be displayed in audit logs + * @returns {Promise} + */ banMember(userID, options) { return this.#client.banGuildMember.call(this.#client, this.id, userID, options); } /** * Ban multiple users from the guild - * @arg {Array} userIDs An array of user IDs to ban - * @arg {Number} [options.deleteMessageSeconds=0] Number of seconds to delete messages for, between 0 and 604800 inclusive - * @arg {String} [options.reason] The reason to be displayed in audit logs + * @param {Array} userIDs An array of user IDs to ban + * @param {Number} [options.deleteMessageSeconds=0] Number of seconds to delete messages for, between 0 and 604800 inclusive + * @param {String} [options.reason] The reason to be displayed in audit logs * @returns {Promise<{ bannedUsers: Array, failedUsers: Array }>} A Promise resolving with an object containing an array of banned users and an array of users for whom the ban operation failed. In case banning all specified users fails, this promise rejects with an error.instead. */ bulkBanMembers(userIDs, options) { @@ -532,36 +532,36 @@ class Guild extends Base { } /** - * Edits command permissions for a multiple commands in a guild. - * Note: You can only add up to 10 permission overwrites for a command. - * @arg {Array} permissions An array of [partial guild command permissions](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure) - * @returns {Promise>} Returns an array of [GuildApplicationCommandPermissions](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure) objects. - */ + * Edits command permissions for a multiple commands in a guild. + * Note: You can only add up to 10 permission overwrites for a command. + * @param {Array} permissions An array of [partial guild command permissions](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure) + * @returns {Promise>} Returns an array of [GuildApplicationCommandPermissions](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure) objects. + */ bulkEditCommandPermissions(permissions) { return this.#client.bulkEditCommandPermissions.call(this.#client, this.id, permissions); } /** - * Bulk create/edit guild application commands - * @arg {Array} commands An array of [Command objects](https://discord.com/developers/docs/interactions/application-commands#application-command-object) - * @returns {Promise} Resolves with a commands object - */ + * Bulk create/edit guild application commands + * @param {Array} commands An array of [Command objects](https://discord.com/developers/docs/interactions/application-commands#application-command-object) + * @returns {Promise} Resolves with a commands object + */ bulkEditCommands(commands) { return this.#client.bulkEditGuildCommands.call(this.#client, this.id, commands); } /** * Create an auto moderation rule - * @arg {Object} options The rule to create - * @arg {Object[]} options.actions The [actions](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object) done when the rule is violated - * @arg {Boolean} [options.enabled=false] If the rule is enabled, false by default - * @arg {Number} options.eventType The [event type](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-event-types) for the rule - * @arg {String[]} [options.exemptChannels] Any channels where this rule does not apply - * @arg {String[]} [options.exemptRoles] Any roles to which this rule does not apply - * @arg {String} options.name The name of the rule - * @arg {String} [options.reason] The reason to be displayed in audit logs - * @arg {Object} [options.triggerMetadata] The [trigger metadata](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-metadata) for the rule - * @arg {Number} options.triggerType The [trigger type](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-types) of the rule + * @param {Object} options The rule to create + * @param {Object[]} options.actions The [actions](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object) done when the rule is violated + * @param {Boolean} [options.enabled=false] If the rule is enabled, false by default + * @param {Number} options.eventType The [event type](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-event-types) for the rule + * @param {String[]} [options.exemptChannels] Any channels where this rule does not apply + * @param {String[]} [options.exemptRoles] Any roles to which this rule does not apply + * @param {String} options.name The name of the rule + * @param {String} [options.reason] The reason to be displayed in audit logs + * @param {Object} [options.triggerMetadata] The [trigger metadata](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-metadata) for the rule + * @param {Number} options.triggerType The [trigger type](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-types) of the rule * @returns {Promise} */ createAutoModerationRule(options) { @@ -569,137 +569,137 @@ class Guild extends Base { } /** - * Create a channel in the guild - * @arg {String} name The name of the channel - * @arg {Number} [type=0] The type of the channel, either 0 (text), 2 (voice), 4 (category), 5 (news), 13 (stage), or 15 (forum) - * @arg {Object | String} [options] The properties the channel should have. - * @arg {Array} [options.availableTags] Available tags for a forum channel - * @arg {Number} [options.bitrate] The bitrate of the channel (voice channels only) - * @arg {Number} [options.defaultAutoArchiveDuration] The default duration of newly created threads in minutes to automatically archive the thread after inactivity (60, 1440, 4320, 10080) - * @arg {Number} [options.defaultForumLayout] The default forum layout view used to display forum posts - * @arg {Object} [options.defaultReactionEmoji] The emoji to show as the reaction button (forum channels only) - * @arg {Object} [options.defaultSortOrder] The default thread sorting order - * @arg {Number} [options.defaultThreadRateLimitPerUser] The initial ratelimit of the channel to use on newly created threads, in seconds. 0 means no ratelimit is enabled - * @arg {Boolean} [options.nsfw] The nsfw status of the channel - * @arg {String?} [options.parentID] The ID of the parent category channel for this channel - * @arg {Array} [options.permissionOverwrites] An array containing permission overwrite objects - * @arg {Number} [options.position] The sorting position of the channel - * @arg {Number} [options.rateLimitPerUser] The time in seconds a user has to wait before sending another message (does not affect bots or users with manageMessages/manageChannel permissions) (text channels only) - * @arg {String} [options.reason] The reason to be displayed in audit logs - * @arg {String} [options.rtcRegion] The RTC region ID of the channel (automatic if `null`) (voice channels only) - * @arg {String} [options.topic] The topic of the channel (text channels only) - * @arg {Number} [options.userLimit] The channel user limit (voice channels only) - * @arg {Number} [options.videoQualityMode] The camera video quality mode of the voice channel (voice channels only). `1` is auto, `2` is 720p - * @returns {Promise} - */ + * Create a channel in the guild + * @param {String} name The name of the channel + * @param {Number} [type=0] The type of the channel, either 0 (text), 2 (voice), 4 (category), 5 (news), 13 (stage), or 15 (forum) + * @param {Object | String} [options] The properties the channel should have. + * @param {Array} [options.availableTags] Available tags for a forum channel + * @param {Number} [options.bitrate] The bitrate of the channel (voice channels only) + * @param {Number} [options.defaultAutoArchiveDuration] The default duration of newly created threads in minutes to automatically archive the thread after inactivity (60, 1440, 4320, 10080) + * @param {Number} [options.defaultForumLayout] The default forum layout view used to display forum posts + * @param {Object} [options.defaultReactionEmoji] The emoji to show as the reaction button (forum channels only) + * @param {Object} [options.defaultSortOrder] The default thread sorting order + * @param {Number} [options.defaultThreadRateLimitPerUser] The initial ratelimit of the channel to use on newly created threads, in seconds. 0 means no ratelimit is enabled + * @param {Boolean} [options.nsfw] The nsfw status of the channel + * @param {String?} [options.parentID] The ID of the parent category channel for this channel + * @param {Array} [options.permissionOverwrites] An array containing permission overwrite objects + * @param {Number} [options.position] The sorting position of the channel + * @param {Number} [options.rateLimitPerUser] The time in seconds a user has to wait before sending another message (does not affect bots or users with manageMessages/manageChannel permissions) (text channels only) + * @param {String} [options.reason] The reason to be displayed in audit logs + * @param {String} [options.rtcRegion] The RTC region ID of the channel (automatic if `null`) (voice channels only) + * @param {String} [options.topic] The topic of the channel (text channels only) + * @param {Number} [options.userLimit] The channel user limit (voice channels only) + * @param {Number} [options.videoQualityMode] The camera video quality mode of the voice channel (voice channels only). `1` is auto, `2` is 720p + * @returns {Promise} + */ createChannel(name, type, options) { return this.#client.createChannel.call(this.#client, this.id, name, type, options); } /** - * Create a guild application command - * @arg {Object} command A command object - * @arg {String} command.name The command name - * @arg {Number} command.type The [type](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types) of command - * @arg {Object} [command.nameLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to names for that locale - * @arg {String} [command.description] The command description (chat input commands only) - * @arg {Object} [command.descriptionLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to descriptions for that locale - * @arg {Array} [command.options] An array of [command options](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure) - * @arg {String} [command.defaultMemberPermissions] The [permissions](https://discord.com/developers/docs/topics/permissions) required by default for this command to be usable - * @returns {Promise} - */ + * Create a guild application command + * @param {Object} command A command object + * @param {String} command.name The command name + * @param {Number} command.type The [type](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types) of command + * @param {Object} [command.nameLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to names for that locale + * @param {String} [command.description] The command description (chat input commands only) + * @param {Object} [command.descriptionLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to descriptions for that locale + * @param {Array} [command.options] An array of [command options](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure) + * @param {String} [command.defaultMemberPermissions] The [permissions](https://discord.com/developers/docs/topics/permissions) required by default for this command to be usable + * @returns {Promise} + */ createCommand(command) { return this.#client.createGuildCommand.call(this.#client, this.id, command); } /** - * Create a emoji in the guild - * @arg {Object} options Emoji options - * @arg {String} options.image The base 64 encoded string - * @arg {String} options.name The name of emoji - * @arg {Array} [options.roles] An array containing authorized role IDs - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} A guild emoji object - */ + * Create a emoji in the guild + * @param {Object} options Emoji options + * @param {String} options.image The base 64 encoded string + * @param {String} options.name The name of emoji + * @param {Array} [options.roles] An array containing authorized role IDs + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} A guild emoji object + */ createEmoji(options, reason) { return this.#client.createGuildEmoji.call(this.#client, this.id, options, reason); } /** - * Create a guild role - * @arg {Object | Role} [options] An object or Role containing the properties to set - * @arg {Number} [options.color] The hex color of the role, in number form (ex: 0x3d15b3 or 4040115) - * @arg {Boolean} [options.hoist] Whether to hoist the role in the user list or not - * @arg {String} [options.icon] The role icon as a base64 data URI - * @arg {Boolean} [options.mentionable] Whether the role is mentionable or not - * @arg {String} [options.name] The name of the role - * @arg {BigInt | Number | String | Permission} [options.permissions] The role permissions - * @arg {String} [options.unicodeEmoji] The role's unicode emoji - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Create a guild role + * @param {Object | Role} [options] An object or Role containing the properties to set + * @param {Number} [options.color] The hex color of the role, in number form (ex: 0x3d15b3 or 4040115) + * @param {Boolean} [options.hoist] Whether to hoist the role in the user list or not + * @param {String} [options.icon] The role icon as a base64 data URI + * @param {Boolean} [options.mentionable] Whether the role is mentionable or not + * @param {String} [options.name] The name of the role + * @param {BigInt | Number | String | Permission} [options.permissions] The role permissions + * @param {String} [options.unicodeEmoji] The role's unicode emoji + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ createRole(options, reason) { return this.#client.createRole.call(this.#client, this.id, options, reason); } /** - * Create a guild scheduled event - * @arg {Object} event The event to be created - * @arg {String} [event.channelID] The channel ID of the event. This is optional if `entityType` is `3` (external) - * @arg {String} [event.description] The description of the event - * @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event. This is required if `entityType` is `3` (external) - * @arg {String} [event.entityMetadata.location] Location of the event - * @arg {Number} event.entityType The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event - * @arg {String} [event.image] Base 64 encoded image for the scheduled event - * @arg {String} event.name The name of the event - * @arg {String} event.privacyLevel The privacy level of the event - * @arg {Date} [event.scheduledEndTime] The time when the event is scheduled to end. This is required if `entityType` is `3` (external) - * @arg {Date} event.scheduledStartTime The time the event will start - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Create a guild scheduled event + * @param {Object} event The event to be created + * @param {String} [event.channelID] The channel ID of the event. This is optional if `entityType` is `3` (external) + * @param {String} [event.description] The description of the event + * @param {Object} [event.entityMetadata] The entity metadata for the scheduled event. This is required if `entityType` is `3` (external) + * @param {String} [event.entityMetadata.location] Location of the event + * @param {Number} event.entityType The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event + * @param {String} [event.image] Base 64 encoded image for the scheduled event + * @param {String} event.name The name of the event + * @param {String} event.privacyLevel The privacy level of the event + * @param {Date} [event.scheduledEndTime] The time when the event is scheduled to end. This is required if `entityType` is `3` (external) + * @param {Date} event.scheduledStartTime The time the event will start + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ createScheduledEvent(event, reason) { return this.#client.createGuildScheduledEvent.call(this.#client, this.id, event, reason); } /** - * Create a guild sticker - * @arg {Object} options Sticker options - * @arg {String} options.description The description of the sticker - * @arg {Object} options.file A file object - * @arg {Buffer} options.file.file A buffer containing file data - * @arg {String} options.file.name What to name the file - * @arg {String} options.name The name of the sticker - * @arg {String} options.tags The Discord name of a unicode emoji representing the sticker's expression - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} A sticker object - */ + * Create a guild sticker + * @param {Object} options Sticker options + * @param {String} options.description The description of the sticker + * @param {Object} options.file A file object + * @param {Buffer} options.file.file A buffer containing file data + * @param {String} options.file.name What to name the file + * @param {String} options.name The name of the sticker + * @param {String} options.tags The Discord name of a unicode emoji representing the sticker's expression + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} A sticker object + */ createSticker(options, reason) { return this.#client.createGuildSticker.call(this.#client, this.id, options, reason); } /** - * Create a template for this guild - * @arg {String} name The name of the template - * @arg {String} [description] The description for the template - * @returns {Promise} - */ + * Create a template for this guild + * @param {String} name The name of the template + * @param {String} [description] The description for the template + * @returns {Promise} + */ createTemplate(name, description) { return this.#client.createGuildTemplate.call(this.#client, this.id, name, description); } /** - * Delete the guild (bot user must be owner) - * @returns {Promise} - */ + * Delete the guild (bot user must be owner) + * @returns {Promise} + */ delete() { return this.#client.deleteGuild.call(this.#client, this.id); } /** * Delete an auto moderation rule - * @arg {String} ruleID The ID of the rule to delete - * @arg {String} [reason] The reason to be displayed in audit logs + * @param {String} ruleID The ID of the rule to delete + * @param {String} [reason] The reason to be displayed in audit logs * @returns {Promise} */ deleteAutoModerationRule(ruleID, reason) { @@ -707,85 +707,85 @@ class Guild extends Base { } /** - * Delete a guild application command - * @arg {String} commandID The command id - * @returns {Promise} - */ + * Delete a guild application command + * @param {String} commandID The command id + * @returns {Promise} + */ deleteCommand(commandID) { return this.#client.deleteGuildCommand.call(this.#client, this.id, commandID); } /** - * Delete a emoji in the guild - * @arg {String} emojiID The ID of the emoji - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Delete a emoji in the guild + * @param {String} emojiID The ID of the emoji + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ deleteEmoji(emojiID, reason) { return this.#client.deleteGuildEmoji.call(this.#client, this.id, emojiID, reason); } /** - * Delete a guild integration - * @arg {String} integrationID The ID of the integration - * @returns {Promise} - */ + * Delete a guild integration + * @param {String} integrationID The ID of the integration + * @returns {Promise} + */ deleteIntegration(integrationID) { return this.#client.deleteGuildIntegration.call(this.#client, this.id, integrationID); } /** - * Delete a role - * @arg {String} roleID The ID of the role - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Delete a role + * @param {String} roleID The ID of the role + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ deleteRole(roleID, reason) { return this.#client.deleteRole.call(this.#client, this.id, roleID, reason); } /** - * Delete a guild scheduled event - * @arg {String} eventID The ID of the event - * @returns {Promise} - */ + * Delete a guild scheduled event + * @param {String} eventID The ID of the event + * @returns {Promise} + */ deleteScheduledEvent(eventID) { return this.#client.deleteGuildScheduledEvent.call(this.#client, this.id, eventID); } /** - * Delete a guild sticker - * @arg {String} stickerID The ID of the sticker - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Delete a guild sticker + * @param {String} stickerID The ID of the sticker + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ deleteSticker(stickerID, reason) { return this.#client.deleteGuildSticker.call(this.#client, this.id, stickerID, reason); } /** - * Delete a guild template - * @arg {String} code The template code - * @returns {Promise} - */ + * Delete a guild template + * @param {String} code The template code + * @returns {Promise} + */ deleteTemplate(code) { return this.#client.deleteGuildTemplate.call(this.#client, this.id, code); } /** - * Get the guild's banner with the given format and size - * @arg {String} [format] The filetype of the icon ("jpg", "jpeg", "png", "gif", or "webp") - * @arg {Number} [size] The size of the icon (any power of two between 16 and 4096) - * @returns {String?} - */ + * Get the guild's banner with the given format and size + * @param {String} [format] The filetype of the icon ("jpg", "jpeg", "png", "gif", or "webp") + * @param {Number} [size] The size of the icon (any power of two between 16 and 4096) + * @returns {String?} + */ dynamicBannerURL(format, size) { return this.banner ? this.#client._formatImage(Endpoints.BANNER(this.id, this.banner), format, size) : null; } /** * Get the guild's discovery splash with the given format and size - * @arg {String} [format] The filetype of the icon ("jpg", "jpeg", "png", "gif", or "webp") - * @arg {Number} [size] The size of the icon (any power of two between 16 and 4096) + * @param {String} [format] The filetype of the icon ("jpg", "jpeg", "png", "gif", or "webp") + * @param {Number} [size] The size of the icon (any power of two between 16 and 4096) * @returns {String?} */ dynamicDiscoverySplashURL(format, size) { @@ -793,66 +793,66 @@ class Guild extends Base { } /** - * Get the guild's icon with the given format and size - * @arg {String} [format] The filetype of the icon ("jpg", "jpeg", "png", "gif", or "webp") - * @arg {Number} [size] The size of the icon (any power of two between 16 and 4096) - * @returns {String?} - */ + * Get the guild's icon with the given format and size + * @param {String} [format] The filetype of the icon ("jpg", "jpeg", "png", "gif", or "webp") + * @param {Number} [size] The size of the icon (any power of two between 16 and 4096) + * @returns {String?} + */ dynamicIconURL(format, size) { return this.icon ? this.#client._formatImage(Endpoints.GUILD_ICON(this.id, this.icon), format, size) : null; } /** - * Get the guild's splash with the given format and size - * @arg {String} [format] The filetype of the icon ("jpg", "jpeg", "png", "gif", or "webp") - * @arg {Number} [size] The size of the icon (any power of two between 16 and 4096) - * @returns {String?} - */ + * Get the guild's splash with the given format and size + * @param {String} [format] The filetype of the icon ("jpg", "jpeg", "png", "gif", or "webp") + * @param {Number} [size] The size of the icon (any power of two between 16 and 4096) + * @returns {String?} + */ dynamicSplashURL(format, size) { return this.splash ? this.#client._formatImage(Endpoints.GUILD_SPLASH(this.id, this.splash), format, size) : null; } /** - * Edit the guild - * @arg {Object} options The properties to edit - * @arg {String} [options.afkChannelID] The ID of the AFK voice channel - * @arg {Number} [options.afkTimeout] The AFK timeout in seconds - * @arg {String} [options.banner] The guild banner image as a base64 data URI (VIP only). Note: base64 strings alone are not base64 data URI strings - * @arg {Number} [options.defaultNotifications] The default notification settings for the guild. 0 is "All Messages", 1 is "Only @mentions". - * @arg {String} [options.description] The description for the guild (VIP only) - * @arg {String} [options.discoverySplash] The guild discovery splash image as a base64 data URI (VIP only). Note: base64 strings alone are not base64 data URI strings - * @arg {Number} [options.explicitContentFilter] The level of the explicit content filter for messages/images in the guild. 0 disables message scanning, 1 enables scanning the messages of members without roles, 2 enables scanning for all messages. - * @arg {Array} [options.features] The enabled features for the guild. Note that only certain features can be toggled with the API - * @arg {String} [options.icon] The guild icon as a base64 data URI. Note: base64 strings alone are not base64 data URI strings - * @arg {String} [options.name] The name of the guild - * @arg {String} [options.ownerID] The ID of the member to transfer guild ownership to (bot user must be owner) - * @arg {String} [options.preferredLocale] Preferred "COMMUNITY" guild language used in server discovery and notices from Discord, and sent in interactions - * @arg {Boolean} [options.premiumProgressBarEnabled] If the boost progress bar is enabled - * @arg {String?} [options.publicUpdatesChannelID] The id of the channel where admins and moderators of "COMMUNITY" guilds receive notices from Discord - * @arg {String?} [options.rulesChannelID] The id of the channel where "COMMUNITY" guilds display rules and/or guidelines - * @arg {String} [options.splash] The guild splash image as a base64 data URI (VIP only). Note: base64 strings alone are not base64 data URI strings - * @arg {Number} [options.systemChannelFlags] The flags for the system channel - * @arg {String?} [options.systemChannelID] The ID of the system channel - * @arg {Number} [options.verificationLevel] The guild verification level - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Edit the guild + * @param {Object} options The properties to edit + * @param {String} [options.afkChannelID] The ID of the AFK voice channel + * @param {Number} [options.afkTimeout] The AFK timeout in seconds + * @param {String} [options.banner] The guild banner image as a base64 data URI (VIP only). Note: base64 strings alone are not base64 data URI strings + * @param {Number} [options.defaultNotifications] The default notification settings for the guild. 0 is "All Messages", 1 is "Only @mentions". + * @param {String} [options.description] The description for the guild (VIP only) + * @param {String} [options.discoverySplash] The guild discovery splash image as a base64 data URI (VIP only). Note: base64 strings alone are not base64 data URI strings + * @param {Number} [options.explicitContentFilter] The level of the explicit content filter for messages/images in the guild. 0 disables message scanning, 1 enables scanning the messages of members without roles, 2 enables scanning for all messages. + * @param {Array} [options.features] The enabled features for the guild. Note that only certain features can be toggled with the API + * @param {String} [options.icon] The guild icon as a base64 data URI. Note: base64 strings alone are not base64 data URI strings + * @param {String} [options.name] The name of the guild + * @param {String} [options.ownerID] The ID of the member to transfer guild ownership to (bot user must be owner) + * @param {String} [options.preferredLocale] Preferred "COMMUNITY" guild language used in server discovery and notices from Discord, and sent in interactions + * @param {Boolean} [options.premiumProgressBarEnabled] If the boost progress bar is enabled + * @param {String?} [options.publicUpdatesChannelID] The id of the channel where admins and moderators of "COMMUNITY" guilds receive notices from Discord + * @param {String?} [options.rulesChannelID] The id of the channel where "COMMUNITY" guilds display rules and/or guidelines + * @param {String} [options.splash] The guild splash image as a base64 data URI (VIP only). Note: base64 strings alone are not base64 data URI strings + * @param {Number} [options.systemChannelFlags] The flags for the system channel + * @param {String?} [options.systemChannelID] The ID of the system channel + * @param {Number} [options.verificationLevel] The guild verification level + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ edit(options, reason) { return this.#client.editGuild.call(this.#client, this.id, options, reason); } /** * edit an existing auto moderation rule - * @arg {String} ruleID The ID of the rule to edit - * @arg {Object} options The rule to create - * @arg {Object[]} [options.actions] The [actions](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object) done when the rule is violated - * @arg {Boolean} [options.enabled=false] If the rule is enabled, false by default - * @arg {Number} [options.eventType] The [event type](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-event-types) for the rule - * @arg {String[]} [options.exemptChannels] Any channels where this rule does not apply - * @arg {String[]} [options.exemptRoles] Any roles to which this rule does not apply - * @arg {String} [options.name] The name of the rule - * @arg {String} [options.reason] The reason to be displayed in audit logs - * @arg {Object} [options.triggerMetadata] The [trigger metadata](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-metadata) for the rule + * @param {String} ruleID The ID of the rule to edit + * @param {Object} options The rule to create + * @param {Object[]} [options.actions] The [actions](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object) done when the rule is violated + * @param {Boolean} [options.enabled=false] If the rule is enabled, false by default + * @param {Number} [options.eventType] The [event type](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-event-types) for the rule + * @param {String[]} [options.exemptChannels] Any channels where this rule does not apply + * @param {String[]} [options.exemptRoles] Any roles to which this rule does not apply + * @param {String} [options.name] The name of the rule + * @param {String} [options.reason] The reason to be displayed in audit logs + * @param {Object} [options.triggerMetadata] The [trigger metadata](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-metadata) for the rule * @returns {Promise} */ editAutoModerationRule(ruleID, options) { @@ -860,72 +860,72 @@ class Guild extends Base { } /** - * Edit multiple channels' positions. Note that channel position numbers are grouped by type (category, text, voice), then sorted in ascending order (lowest number is on top). - * @arg {Array} channelPositions An array of [ChannelPosition](https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions) - * @arg {String} channelPositions[].id The ID of the channel - * @arg {Number} [channelPositions[].position] The new position of the channel - * @arg {Boolean} [channelPositions[].lockPermissions] Whether to sync the channel's permissions with the new parent, if changing parents - * @arg {String} [channelPositions[].parentID] The new parent ID (category channel) for the channel that is moved. For each request, only one channel can change parents - * @returns {Promise} - */ + * Edit multiple channels' positions. Note that channel position numbers are grouped by type (category, text, voice), then sorted in ascending order (lowest number is on top). + * @param {Array} channelPositions An array of [ChannelPosition](https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions) + * @param {String} channelPositions[].id The ID of the channel + * @param {Number} [channelPositions[].position] The new position of the channel + * @param {Boolean} [channelPositions[].lockPermissions] Whether to sync the channel's permissions with the new parent, if changing parents + * @param {String} [channelPositions[].parentID] The new parent ID (category channel) for the channel that is moved. For each request, only one channel can change parents + * @returns {Promise} + */ editChannelPositions(channelPositions) { return this.#client.editChannelPositions.call(this.#client, this.id, channelPositions); } /** - * Edit a guild application command - * @arg {String} commandID The command id - * @arg {Object} command A command object - * @arg {String} [command.name] The command name - * @arg {Object} [command.nameLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to names for that locale - * @arg {String} [command.description] The command description (chat input commands only) - * @arg {Object} [command.descriptionLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to descriptions for that locale - * @arg {Array} [command.options] An array of [command options](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure) - * @arg {String} [command.defaultMemberPermissions] The [permissions](https://discord.com/developers/docs/topics/permissions) required by default for this command to be usable - * @returns {Promise} - */ + * Edit a guild application command + * @param {String} commandID The command id + * @param {Object} command A command object + * @param {String} [command.name] The command name + * @param {Object} [command.nameLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to names for that locale + * @param {String} [command.description] The command description (chat input commands only) + * @param {Object} [command.descriptionLocalizations] A map of [locales](https://discord.com/developers/docs/reference#locales) to descriptions for that locale + * @param {Array} [command.options] An array of [command options](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure) + * @param {String} [command.defaultMemberPermissions] The [permissions](https://discord.com/developers/docs/topics/permissions) required by default for this command to be usable + * @returns {Promise} + */ editCommand(commandID, command) { return this.#client.editGuildCommand.call(this.#client, this.id, commandID, command); } /** - * Edits command permissions for a specific command in a guild. - * Note: You can only add up to 10 permission overwrites for a command. - * @arg {String} commandID The command id - * @arg {Array} permissions An array of [permissions objects](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-structure) - * @returns {Promise} Resolves with a [GuildApplicationCommandPermissions](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure) object. - */ + * Edits command permissions for a specific command in a guild. + * Note: You can only add up to 10 permission overwrites for a command. + * @param {String} commandID The command id + * @param {Array} permissions An array of [permissions objects](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-structure) + * @returns {Promise} Resolves with a [GuildApplicationCommandPermissions](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure) object. + */ editCommandPermissions(commandID, permissions) { return this.#client.editCommandPermissions.call(this.#client, this.id, commandID, permissions); } /** - * Edit a emoji in the guild - * @arg {String} emojiID The ID of the emoji you want to modify - * @arg {Object} options Emoji options - * @arg {String} [options.name] The name of emoji - * @arg {Array} [options.roles] An array containing authorized role IDs - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} A guild emoji object - */ + * Edit a emoji in the guild + * @param {String} emojiID The ID of the emoji you want to modify + * @param {Object} options Emoji options + * @param {String} [options.name] The name of emoji + * @param {Array} [options.roles] An array containing authorized role IDs + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} A guild emoji object + */ editEmoji(emojiID, options, reason) { return this.#client.editGuildEmoji.call(this.#client, this.id, emojiID, options, reason); } /** - * Edit a guild member - * @arg {String} memberID The ID of the member (use "@me" to edit the current bot user) - * @arg {Object} options The properties to edit - * @arg {String?} [options.channelID] The ID of the voice channel to move the member to (must be in voice). Set to `null` to disconnect the member - * @arg {Date?} [options.communicationDisabledUntil] When the user's timeout should expire. Set to `null` to instantly remove timeout - * @arg {Boolean} [options.deaf] Server deafen the member - * @arg {Number} [options.flags] The guild member flag bit set - * @arg {Boolean} [options.mute] Server mute the member - * @arg {String} [options.nick] Set the member's guild nickname, "" to remove - * @arg {Array} [options.roles] The array of role IDs the member should have - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Edit a guild member + * @param {String} memberID The ID of the member (use "@me" to edit the current bot user) + * @param {Object} options The properties to edit + * @param {String?} [options.channelID] The ID of the voice channel to move the member to (must be in voice). Set to `null` to disconnect the member + * @param {Date?} [options.communicationDisabledUntil] When the user's timeout should expire. Set to `null` to instantly remove timeout + * @param {Boolean} [options.deaf] Server deafen the member + * @param {Number} [options.flags] The guild member flag bit set + * @param {Boolean} [options.mute] Server mute the member + * @param {String} [options.nick] Set the member's guild nickname, "" to remove + * @param {Array} [options.roles] The array of role IDs the member should have + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ editMember(memberID, options, reason) { return this.#client.editGuildMember.call(this.#client, this.id, memberID, options, reason); } @@ -952,152 +952,152 @@ class Guild extends Base { } /** - * Edit the guild role - * @arg {String} roleID The ID of the role - * @arg {Object} options The properties to edit - * @arg {Number} [options.color] The hex color of the role, in number form (ex: 0x3da5b3 or 4040115) - * @arg {Boolean} [options.hoist] Whether to hoist the role in the user list or not - * @arg {String} [options.icon] The role icon as a base64 data URI - * @arg {Boolean} [options.mentionable] Whether the role is mentionable or not - * @arg {String} [options.name] The name of the role - * @arg {BigInt | Number | String | Permission} [options.permissions] The role permissions - * @arg {String} [options.unicodeEmoji] The role's unicode emoji - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Edit the guild role + * @param {String} roleID The ID of the role + * @param {Object} options The properties to edit + * @param {Number} [options.color] The hex color of the role, in number form (ex: 0x3da5b3 or 4040115) + * @param {Boolean} [options.hoist] Whether to hoist the role in the user list or not + * @param {String} [options.icon] The role icon as a base64 data URI + * @param {Boolean} [options.mentionable] Whether the role is mentionable or not + * @param {String} [options.name] The name of the role + * @param {BigInt | Number | String | Permission} [options.permissions] The role permissions + * @param {String} [options.unicodeEmoji] The role's unicode emoji + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ editRole(roleID, options, reason) { return this.#client.editRole.call(this.#client, this.id, roleID, options, reason); } /** - * Edit this scheduled event - * @arg {String} eventID The guild scheduled event ID - * @arg {Object} event The new guild scheduled event object - * @arg {String} [event.channelID] The channel ID of the event. If updating `entityType` to `3` (external), this **must** be set to `null` - * @arg {String} [event.description] The description of the event - * @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event. This is required if updating `entityType` to `3` (external) - * @arg {String} [event.entityMetadata.location] Location of the event. This is required if updating `entityType` to `3` (external) - * @arg {Number} [event.entityType] The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event - * @arg {String} [event.image] Base 64 encoded image for the event - * @arg {String} [event.name] The name of the event - * @arg {String} [event.privacyLevel] The privacy level of the event - * @arg {Date} [event.scheduledEndTime] The time when the scheduled event is scheduled to end. This is required if updating `entityType` to `3` (external) - * @arg {Date} [event.scheduledStartTime] The time the event will start - * @arg {Number} [event.status] The [status](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status) of the scheduled event - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Edit this scheduled event + * @param {String} eventID The guild scheduled event ID + * @param {Object} event The new guild scheduled event object + * @param {String} [event.channelID] The channel ID of the event. If updating `entityType` to `3` (external), this **must** be set to `null` + * @param {String} [event.description] The description of the event + * @param {Object} [event.entityMetadata] The entity metadata for the scheduled event. This is required if updating `entityType` to `3` (external) + * @param {String} [event.entityMetadata.location] Location of the event. This is required if updating `entityType` to `3` (external) + * @param {Number} [event.entityType] The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event + * @param {String} [event.image] Base 64 encoded image for the event + * @param {String} [event.name] The name of the event + * @param {String} [event.privacyLevel] The privacy level of the event + * @param {Date} [event.scheduledEndTime] The time when the scheduled event is scheduled to end. This is required if updating `entityType` to `3` (external) + * @param {Date} [event.scheduledStartTime] The time the event will start + * @param {Number} [event.status] The [status](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status) of the scheduled event + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ editScheduledEvent(eventID, event, reason) { return this.#client.editGuildScheduledEvent.call(this.#client, this.id, eventID, event, reason); } /** - * Edit a guild sticker - * @arg {String} stickerID The ID of the sticker - * @arg {Object} options The properties to edit - * @arg {String} [options.description] The description of the sticker - * @arg {String} [options.name] The name of the sticker - * @arg {String} [options.tags] The Discord name of a unicode emoji representing the sticker's expression - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} A sticker object - */ + * Edit a guild sticker + * @param {String} stickerID The ID of the sticker + * @param {Object} options The properties to edit + * @param {String} [options.description] The description of the sticker + * @param {String} [options.name] The name of the sticker + * @param {String} [options.tags] The Discord name of a unicode emoji representing the sticker's expression + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} A sticker object + */ editSticker(stickerID, options, reason) { return this.#client.editGuildSticker.call(this.#client, this.id, stickerID, options, reason); } /** - * Edit a guild template - * @arg {String} code The template code - * @arg {Object} options The properties to edit - * @arg {String} [options.name] The name of the template - * @arg {String?} [options.description] The desription for the template. Set to `null` to remove the description - * @returns {Promise} - */ + * Edit a guild template + * @param {String} code The template code + * @param {Object} options The properties to edit + * @param {String} [options.name] The name of the template + * @param {String?} [options.description] The desription for the template. Set to `null` to remove the description + * @returns {Promise} + */ editTemplate(code, options) { return this.#client.editGuildTemplate.call(this.#client, this.id, code, options); } /** - * Update a user's voice state - See [caveats](https://discord.com/developers/docs/resources/guild#modify-user-voice-state-caveats) - * @arg {Object} options The properties to edit - * @arg {String} options.channelID The ID of the channel the user is currently in - * @arg {Date?} [options.requestToSpeakTimestamp] Sets the user's request to speak - this can only be used when the `userID` param is "@me" - * @arg {Boolean} [options.suppress] Toggles the user's suppress state - * @arg {String} [userID="@me"] The user ID of the user to update - * @returns {Promise} - */ + * Update a user's voice state - See [caveats](https://discord.com/developers/docs/resources/guild#modify-user-voice-state-caveats) + * @param {Object} options The properties to edit + * @param {String} options.channelID The ID of the channel the user is currently in + * @param {Date?} [options.requestToSpeakTimestamp] Sets the user's request to speak - this can only be used when the `userID` param is "@me" + * @param {Boolean} [options.suppress] Toggles the user's suppress state + * @param {String} [userID="@me"] The user ID of the user to update + * @returns {Promise} + */ editVoiceState(options, userID) { return this.#client.editGuildVoiceState.call(this.#client, this.id, options, userID); } /** - * Edit the guild welcome screen - * @arg {Object} [options] The properties to edit - * @arg {String?} [options.description] The description in the welcome screen - * @arg {Boolean} [options.enabled] Whether the welcome screen is enabled - * @arg {Array} [options.welcomeChannels] The list of channels in the welcome screen as an array - * @arg {String} options.welcomeChannels[].channelID The channel ID of the welcome channel - * @arg {String} options.welcomeChannels[].description The description of the welcome channel - * @arg {String?} options.welcomeChannels[].emojiID The emoji ID of the welcome channel - * @arg {String?} options.welcomeChannels[].emojiName The emoji name of the welcome channel - * @returns {Promise} - */ + * Edit the guild welcome screen + * @param {Object} [options] The properties to edit + * @param {String?} [options.description] The description in the welcome screen + * @param {Boolean} [options.enabled] Whether the welcome screen is enabled + * @param {Array} [options.welcomeChannels] The list of channels in the welcome screen as an array + * @param {String} options.welcomeChannels[].channelID The channel ID of the welcome channel + * @param {String} options.welcomeChannels[].description The description of the welcome channel + * @param {String?} options.welcomeChannels[].emojiID The emoji ID of the welcome channel + * @param {String?} options.welcomeChannels[].emojiName The emoji name of the welcome channel + * @returns {Promise} + */ editWelcomeScreen(options) { return this.#client.editGuildWelcomeScreen.call(this.#client, this.id, options); } /** - * Modify a guild's widget - * @arg {Object} options The widget object to modify (https://discord.com/developers/docs/resources/guild#modify-guild-widget) - * @arg {Boolean} [options.enabled] Whether the guild widget is enabled - * @arg {String?} [options.channel_id] The channel ID for the guild widget - * @arg {String?} [options.reason] The reason to be displayed in audit logs - * @returns {Promise} A guild widget object - */ + * Modify a guild's widget + * @param {Object} options The widget object to modify (https://discord.com/developers/docs/resources/guild#modify-guild-widget) + * @param {Boolean} [options.enabled] Whether the guild widget is enabled + * @param {String?} [options.channel_id] The channel ID for the guild widget + * @param {String?} [options.reason] The reason to be displayed in audit logs + * @returns {Promise} A guild widget object + */ editWidget(options) { return this.#client.editGuildWidget.call(this.#client, this.id, options); } /** - * Request specific guild members through the gateway connection - * @arg {Object} [options] Options for fetching the members - * @arg {Number} [options.limit] The maximum number of members to fetch - * @arg {Boolean} [options.presences] Whether to request member presences or not. When using intents, the `GUILD_PRESENCES` intent is required. - * @arg {String} [options.query] The query used for looking up the members. When using intents, `GUILD_MEMBERS` is required to fetch all members. - * @arg {Number} [options.timeout] The number of milliseconds to wait before resolving early. Defaults to the `requestTimeout` client option - * @arg {Array} [options.userIDs] The IDs of members to fetch - * @returns {Promise>} Resolves with the fetched members. - */ + * Request specific guild members through the gateway connection + * @param {Object} [options] Options for fetching the members + * @param {Number} [options.limit] The maximum number of members to fetch + * @param {Boolean} [options.presences] Whether to request member presences or not. When using intents, the `GUILD_PRESENCES` intent is required. + * @param {String} [options.query] The query used for looking up the members. When using intents, `GUILD_MEMBERS` is required to fetch all members. + * @param {Number} [options.timeout] The number of milliseconds to wait before resolving early. Defaults to the `requestTimeout` client option + * @param {Array} [options.userIDs] The IDs of members to fetch + * @returns {Promise>} Resolves with the fetched members. + */ fetchMembers(options) { return this.shard.requestGuildMembers(this.id, options); } /** - * Get all active threads in this guild - * @returns {Promise} An object containing an array of `threads` and an array of `members` - */ + * Get all active threads in this guild + * @returns {Promise} An object containing an array of `threads` and an array of `members` + */ getActiveThreads() { return this.#client.getActiveGuildThreads.call(this.#client, this.id); } /** - * Get the audit log for the guild - * @arg {Object} [options] Options for the request. - * @arg {Number} [options.actionType] Filter entries by action type - * @arg {String} [options.after] Get entries after this entry ID - * @arg {String} [options.before] Get entries before this entry ID - * @arg {Number} [options.limit=50] The maximum number of entries to return - * @arg {String} [options.userID] Filter entries by the user that performed the action - * @returns {Promise<{entries: Array, integrations: Array, threads: Array, users: Array, webhooks: Array}>} - */ + * Get the audit log for the guild + * @param {Object} [options] Options for the request. + * @param {Number} [options.actionType] Filter entries by action type + * @param {String} [options.after] Get entries after this entry ID + * @param {String} [options.before] Get entries before this entry ID + * @param {Number} [options.limit=50] The maximum number of entries to return + * @param {String} [options.userID] Filter entries by the user that performed the action + * @returns {Promise<{entries: Array, integrations: Array, threads: Array, users: Array, webhooks: Array}>} + */ getAuditLog(options) { return this.#client.getGuildAuditLog.call(this.#client, this.id, options); } /** * Get an existing auto moderation rule - * @arg {String} guildID The ID of the guild to get the rule from - * @arg {String} ruleID The ID of the rule to get + * @param {String} guildID The ID of the guild to get the rule from + * @param {String} ruleID The ID of the rule to get * @returns {Promise} */ getAutoModerationRule(ruleID) { @@ -1106,7 +1106,7 @@ class Guild extends Base { /** * Get a guild's auto moderation rules - * @arg {String} guildID The ID of the guild to get the rules of + * @param {String} guildID The ID of the guild to get the rules of * @returns {Promise} */ getAutoModerationRules() { @@ -1114,74 +1114,74 @@ class Guild extends Base { } /** - * Get a ban from the ban list of a guild - * @arg {String} userID The ID of the banned user - * @returns {Promise} Resolves with {reason: String, user: User} - */ + * Get a ban from the ban list of a guild + * @param {String} userID The ID of the banned user + * @returns {Promise} Resolves with {reason: String, user: User} + */ getBan(userID) { return this.#client.getGuildBan.call(this.#client, this.id, userID); } /** - * Get the ban list of the guild - * @arg {Object} [options] Options for the request - * @arg {String} [options.after] Only get users after given user ID - * @arg {String} [options.before] Only get users before given user ID - * @arg {Number} [options.limit=1000] The maximum number of users to return - * @returns {Promise>} Resolves with an array of { reason: String, user: User } - */ + * Get the ban list of the guild + * @param {Object} [options] Options for the request + * @param {String} [options.after] Only get users after given user ID + * @param {String} [options.before] Only get users before given user ID + * @param {Number} [options.limit=1000] The maximum number of users to return + * @returns {Promise>} Resolves with an array of { reason: String, user: User } + */ getBans(options) { return this.#client.getGuildBans.call(this.#client, this.id, options); } /** - * Get a guild application command - * @arg {String} commandID The command id - * @arg {Boolean} withLocalizations Include [localizations](https://discord.com/developers/docs/interactions/application-commands#retrieving-localized-commands) in the response - * @returns {Promise} Resolves with a command object - */ + * Get a guild application command + * @param {String} commandID The command id + * @param {Boolean} withLocalizations Include [localizations](https://discord.com/developers/docs/interactions/application-commands#retrieving-localized-commands) in the response + * @returns {Promise} Resolves with a command object + */ getCommand(commandID, withLocalizations) { return this.#client.getGuildCommand.call(this.#client, this.id, commandID, withLocalizations); } /** - * Get the a guild's application command permissions - * @arg {String} commandID The command id - * @returns {Promise} Resolves with a guild application command permissions object. - */ + * Get the a guild's application command permissions + * @param {String} commandID The command id + * @returns {Promise} Resolves with a guild application command permissions object. + */ getCommandPermissions(commandID) { return this.#client.getCommandPermissions.call(this.#client, this.id, commandID); } /** - * Get the guild's application commands - * @arg {Boolean} withLocalizations Include [localizations](https://discord.com/developers/docs/interactions/application-commands#retrieving-localized-commands) in the response - * @returns {Promise>} Resolves with an array of command objects - */ + * Get the guild's application commands + * @param {Boolean} withLocalizations Include [localizations](https://discord.com/developers/docs/interactions/application-commands#retrieving-localized-commands) in the response + * @returns {Promise>} Resolves with an array of command objects + */ getCommands(withLocalizations) { return this.#client.getGuildCommands.call(this.#client, this.id, withLocalizations); } /** - * Get the all of a guild's application command permissions - * @returns {Promise>} Resolves with an array of guild application command permissions objects. - */ + * Get the all of a guild's application command permissions + * @returns {Promise>} Resolves with an array of guild application command permissions objects. + */ getGuildCommandPermissions() { return this.#client.getGuildCommandPermissions.call(this.#client, this.id); } /** - * Get a list of integrations for the guild - * @returns {Promise>} - */ + * Get a list of integrations for the guild + * @returns {Promise>} + */ getIntegrations() { return this.#client.getGuildIntegrations.call(this.#client, this.id); } /** - * Get all invites in the guild - * @returns {Promise>} - */ + * Get all invites in the guild + * @returns {Promise>} + */ getInvites() { return this.#client.getGuildInvites.call(this.#client, this.id); } @@ -1195,207 +1195,207 @@ class Guild extends Base { } /** - * Get the prune count for the guild - * @arg {Number} [options] The options to use to get number of prune members - * @arg {Number} [options.days=7] The number of days of inactivity to prune for - * @arg {Array} [options.includeRoles] An array of role IDs that members must have to be considered for pruning - * @returns {Promise} Resolves with the number of members that would be pruned - */ + * Get the prune count for the guild + * @param {Number} [options] The options to use to get number of prune members + * @param {Number} [options.days=7] The number of days of inactivity to prune for + * @param {Array} [options.includeRoles] An array of role IDs that members must have to be considered for pruning + * @returns {Promise} Resolves with the number of members that would be pruned + */ getPruneCount(options) { return this.#client.getPruneCount.call(this.#client, this.id, options); } /** - * Get a guild's channels via the REST API. REST mode is required to use this endpoint. - * @returns {Promise>} - */ + * Get a guild's channels via the REST API. REST mode is required to use this endpoint. + * @returns {Promise>} + */ getRESTChannels() { return this.#client.getRESTGuildChannels.call(this.#client, this.id); } /** - * Get a guild emoji via the REST API. REST mode is required to use this endpoint. - * @arg {String} emojiID The ID of the emoji - * @returns {Promise} An emoji object - */ + * Get a guild emoji via the REST API. REST mode is required to use this endpoint. + * @param {String} emojiID The ID of the emoji + * @returns {Promise} An emoji object + */ getRESTEmoji(emojiID) { return this.#client.getRESTGuildEmoji.call(this.#client, this.id, emojiID); } /** - * Get a guild's emojis via the REST API. REST mode is required to use this endpoint. - * @returns {Promise>} An array of guild emoji objects - */ + * Get a guild's emojis via the REST API. REST mode is required to use this endpoint. + * @returns {Promise>} An array of guild emoji objects + */ getRESTEmojis() { return this.#client.getRESTGuildEmojis.call(this.#client, this.id); } /** - * Get a guild's members via the REST API. REST mode is required to use this endpoint. - * @arg {String} memberID The ID of the member - * @returns {Promise} - */ + * Get a guild's members via the REST API. REST mode is required to use this endpoint. + * @param {String} memberID The ID of the member + * @returns {Promise} + */ getRESTMember(memberID) { return this.#client.getRESTGuildMember.call(this.#client, this.id, memberID); } /** - * Get a guild's members via the REST API. REST mode is required to use this endpoint. - * @arg {Object} [options] Options for the request - * @arg {String} [options.after] The highest user ID of the previous page - * @arg {Number} [options.limit=1] The max number of members to get (1 to 1000) - * @returns {Promise>} - */ + * Get a guild's members via the REST API. REST mode is required to use this endpoint. + * @param {Object} [options] Options for the request + * @param {String} [options.after] The highest user ID of the previous page + * @param {Number} [options.limit=1] The max number of members to get (1 to 1000) + * @returns {Promise>} + */ getRESTMembers(options) { return this.#client.getRESTGuildMembers.call(this.#client, this.id, options); } /** - * Get a guild's roles via the REST API. REST mode is required to use this endpoint. - * @returns {Promise>} - */ + * Get a guild's roles via the REST API. REST mode is required to use this endpoint. + * @returns {Promise>} + */ getRESTRoles() { return this.#client.getRESTGuildRoles.call(this.#client, this.id); } /** - * Get a guild scheduled event via the REST API. REST mode is required to use this endpoint. - * @arg {String} eventID The ID of the guild scheduled event - * @arg {Object} [options] Options for the request - * @arg {Boolean} [options.withUserCount] Whether to include the number of users subscribed to the event - * @returns {Promise} - */ + * Get a guild scheduled event via the REST API. REST mode is required to use this endpoint. + * @param {String} eventID The ID of the guild scheduled event + * @param {Object} [options] Options for the request + * @param {Boolean} [options.withUserCount] Whether to include the number of users subscribed to the event + * @returns {Promise} + */ getRESTScheduledEvent(eventID, options) { return this.#client.getRESTGuildScheduledEvent.call(this.#client, this.id, eventID, options); } /** - * Get a guild sticker via the REST API. REST mode is required to use this endpoint. - * @arg {String} stickerID The ID of the sticker - * @returns {Promise} A sticker object - */ + * Get a guild sticker via the REST API. REST mode is required to use this endpoint. + * @param {String} stickerID The ID of the sticker + * @returns {Promise} A sticker object + */ getRESTSticker(stickerID) { return this.#client.getRESTGuildSticker.call(this.#client, this.id, stickerID); } /** - * Get a guild's stickers via the REST API. REST mode is required to use this endpoint. - * @returns {Promise>} An array of guild sticker objects - */ + * Get a guild's stickers via the REST API. REST mode is required to use this endpoint. + * @returns {Promise>} An array of guild sticker objects + */ getRESTStickers() { return this.#client.getRESTGuildStickers.call(this.#client, this.id); } /** - * Get the guild's scheduled events - * @arg {Object} [options] Options for the request - * @arg {Boolean} [options.withUserCount] Whether to include the number of users subscribed to each event - * @returns {Promise>} - */ + * Get the guild's scheduled events + * @param {Object} [options] Options for the request + * @param {Boolean} [options.withUserCount] Whether to include the number of users subscribed to each event + * @returns {Promise>} + */ getScheduledEvents(options) { return this.#client.getGuildScheduledEvents.call(this.#client, this.id, options); } /** - * Get a list of users subscribed to a guild scheduled event - * @arg {String} eventID The ID of the event - * @arg {Object} [options] Options for the request - * @arg {String} [options.after] Get users after this user ID. If `options.before` is provided, this will be ignored. Fetching users in between `before` and `after` is not supported - * @arg {String} [options.before] Get users before this user ID - * @arg {Number} [options.limit=100] The number of users to get (max 100). Pagination will only work if one of `options.after` or `options.after` is also provided - * @arg {Boolean} [options.withMember] Include guild member data - * @returns {Promise>} - */ + * Get a list of users subscribed to a guild scheduled event + * @param {String} eventID The ID of the event + * @param {Object} [options] Options for the request + * @param {String} [options.after] Get users after this user ID. If `options.before` is provided, this will be ignored. Fetching users in between `before` and `after` is not supported + * @param {String} [options.before] Get users before this user ID + * @param {Number} [options.limit=100] The number of users to get (max 100). Pagination will only work if one of `options.after` or `options.after` is also provided + * @param {Boolean} [options.withMember] Include guild member data + * @returns {Promise>} + */ getScheduledEventUsers(eventID, options) { return this.#client.getGuildScheduledEventUsers.call(this.#client, this.id, eventID, options); } /** - * Get the guild's templates - * @returns {Promise>} - */ + * Get the guild's templates + * @returns {Promise>} + */ getTemplates() { return this.#client.getGuildTemplates.call(this.#client, this.id); } /** - * Returns the vanity url of the guild - * @returns {Promise} - */ + * Returns the vanity url of the guild + * @returns {Promise} + */ getVanity() { return this.#client.getGuildVanity.call(this.#client, this.id); } /** - * Get possible voice regions for a guild - * @returns {Promise>} Resolves with an array of voice region objects - */ + * Get possible voice regions for a guild + * @returns {Promise>} Resolves with an array of voice region objects + */ getVoiceRegions() { return this.#client.getVoiceRegions.call(this.#client, this.id); } /** - * Get all the webhooks in the guild - * @returns {Promise>} Resolves with an array of webhook objects - */ + * Get all the webhooks in the guild + * @returns {Promise>} Resolves with an array of webhook objects + */ getWebhooks() { return this.#client.getGuildWebhooks.call(this.#client, this.id); } /** - * Get the welcome screen of the Community guild, shown to new members - * @returns {Promise} - */ + * Get the welcome screen of the Community guild, shown to new members + * @returns {Promise} + */ getWelcomeScreen() { return this.#client.getGuildWelcomeScreen.call(this.#client, this.id); } /** - * Get a guild's widget object - * @returns {Promise} A guild widget object - */ + * Get a guild's widget object + * @returns {Promise} A guild widget object + */ getWidget() { return this.#client.getGuildWidget.call(this.#client, this.id); } /** - * Get a guild's widget settings object - * @returns {Promise} A guild widget settings object - */ + * Get a guild's widget settings object + * @returns {Promise} A guild widget settings object + */ getWidgetSettings() { return this.#client.getGuildWidgetSettings.call(this.#client, this.id); } /** - * Kick a member from the guild - * @arg {String} userID The ID of the member - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Kick a member from the guild + * @param {String} userID The ID of the member + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ kickMember(userID, reason) { return this.#client.kickGuildMember.call(this.#client, this.id, userID, reason); } /** - * Leave the guild - * @returns {Promise} - */ + * Leave the guild + * @returns {Promise} + */ leave() { return this.#client.leaveGuild.call(this.#client, this.id); } /** - * Leaves the voice channel in this guild - */ + * Leaves the voice channel in this guild + */ leaveVoiceChannel() { this.#client.closeVoiceConnection.call(this.#client, this.id); } /** - * Get the guild permissions of a member - * @arg {String | Member | Object} memberID The ID of the member or a Member object - * @returns {Permission} - */ + * Get the guild permissions of a member + * @param {String | Member | Object} memberID The ID of the member or a Member object + * @returns {Permission} + */ permissionsOf(memberID) { const member = typeof memberID === "string" ? this.members.get(memberID) : memberID; if(member.id === this.ownerID) { @@ -1424,54 +1424,54 @@ class Guild extends Base { } /** - * Begin pruning the guild - * @arg {Number} [options] The options to pass to prune members - * @arg {Boolean} [options.computePruneCount=true] Whether or not the number of pruned members should be returned. Discord discourages setting this to true for larger guilds - * @arg {Number} [options.days=7] The number of days of inactivity to prune for - * @arg {Array} [options.includeRoles] An array of role IDs that members must have to be considered for pruning - * @arg {String} [options.reason] The reason to be displayed in audit logs - * @returns {Promise} Resolves with the number of pruned members - */ + * Begin pruning the guild + * @param {Number} [options] The options to pass to prune members + * @param {Boolean} [options.computePruneCount=true] Whether or not the number of pruned members should be returned. Discord discourages setting this to true for larger guilds + * @param {Number} [options.days=7] The number of days of inactivity to prune for + * @param {Array} [options.includeRoles] An array of role IDs that members must have to be considered for pruning + * @param {String} [options.reason] The reason to be displayed in audit logs + * @returns {Promise} Resolves with the number of pruned members + */ pruneMembers(options) { return this.#client.pruneMembers.call(this.#client, this.id, options); } /** - * Remove a role from a guild member - * @arg {String} memberID The ID of the member - * @arg {String} roleID The ID of the role - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Remove a role from a guild member + * @param {String} memberID The ID of the member + * @param {String} roleID The ID of the role + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ removeMemberRole(memberID, roleID, reason) { return this.#client.removeGuildMemberRole.call(this.#client, this.id, memberID, roleID, reason); } /** - * Search for guild members by partial nickname/username - * @arg {String} query The query string to match username(s) and nickname(s) against - * @arg {Number} [limit=1] The maximum number of members you want returned, capped at 100 - * @returns {Promise>} - */ + * Search for guild members by partial nickname/username + * @param {String} query The query string to match username(s) and nickname(s) against + * @param {Number} [limit=1] The maximum number of members you want returned, capped at 100 + * @returns {Promise>} + */ searchMembers(query, limit) { return this.#client.searchGuildMembers.call(this.#client, this.id, query, limit); } /** - * Force a guild template to sync - * @arg {String} code The template code - * @returns {Promise} - */ + * Force a guild template to sync + * @param {String} code The template code + * @returns {Promise} + */ syncTemplate(code) { return this.#client.syncGuildTemplate.call(this.#client, this.id, code); } /** - * Unban a user from the guild - * @arg {String} userID The ID of the member - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Unban a user from the guild + * @param {String} userID The ID of the member + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ unbanMember(userID, reason) { return this.#client.unbanGuildMember.call(this.#client, this.id, userID, reason); } diff --git a/lib/structures/GuildAuditLogEntry.js b/lib/structures/GuildAuditLogEntry.js index e366f701..166d57d2 100644 --- a/lib/structures/GuildAuditLogEntry.js +++ b/lib/structures/GuildAuditLogEntry.js @@ -5,9 +5,9 @@ const Invite = require("./Invite"); const {AuditLogActions} = require("../Constants"); /** -* Represents a guild audit log entry describing a moderation action -* @extends Base -*/ + * Represents a guild audit log entry describing a moderation action + * @extends Base + */ class GuildAuditLogEntry extends Base { /** * The ID of the entry diff --git a/lib/structures/GuildChannel.js b/lib/structures/GuildChannel.js index b8eaf878..cfaca8ba 100644 --- a/lib/structures/GuildChannel.js +++ b/lib/structures/GuildChannel.js @@ -5,9 +5,9 @@ const Permission = require("./Permission"); const {Permissions} = require("../Constants"); /** -* Represents a guild channel. You also probably want to look at CategoryChannel, NewsChannel, StoreChannel, TextChannel, ThreadChannel, and TextVoiceChannel. -* @extends Channel -*/ + * Represents a guild channel. You also probably want to look at CategoryChannel, NewsChannel, StoreChannel, TextChannel, ThreadChannel, and TextVoiceChannel. + * @extends Channel + */ class GuildChannel extends Channel { #client; constructor(data, client) { @@ -60,85 +60,85 @@ class GuildChannel extends Channel { } /** - * Delete the channel - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Delete the channel + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ delete(reason) { return this.#client.deleteChannel.call(this.#client, this.id, reason); } /** - * Delete a channel permission overwrite - * @arg {String} overwriteID The ID of the overwritten user or role - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Delete a channel permission overwrite + * @param {String} overwriteID The ID of the overwritten user or role + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ deletePermission(overwriteID, reason) { return this.#client.deleteChannelPermission.call(this.#client, this.id, overwriteID, reason); } /** - * Edit the channel's properties - * @arg {Object} options The properties to edit - * @arg {Boolean} [options.archived] The archive status of the channel (thread channels only) - * @arg {Array} [options.appliedTags] An array of applied tag IDs for the thread (available only in threads in thread-only channels) - * @arg {Number} [options.autoArchiveDuration] The duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080 (thread channels only) - * @arg {Array} [options.availableTags] Available tags for a forum channel - * @arg {Number} [options.bitrate] The bitrate of the channel (guild voice channels only) - * @arg {Number?} [options.defaultAutoArchiveDuration] The default duration of newly created threads in minutes to automatically archive the thread after inactivity (60, 1440, 4320, 10080) (guild text/news channels only) - * @arg {Object} [options.defaultReactionEmoji] The emoji to show as the reaction button (forum channels only) - * @arg {Number} [options.defaultSortOrder] The default thread sorting order - * @arg {Number} [options.defaultThreadRateLimitPerUser] The initial ratelimit of the channel to use on newly created threads, in seconds. 0 means no ratelimit is enabled - * @arg {Boolean} [options.invitable] Whether non-moderators can add other non-moderators to the channel (private thread channels only) - * @arg {Boolean} [options.locked] The lock status of the channel (thread channels only) - * @arg {String} [options.name] The name of the channel - * @arg {Boolean} [options.nsfw] The nsfw status of the channel - * @arg {Number?} [options.parentID] The ID of the parent channel category for this channel (guild text/voice channels only) or the channel ID where the thread originated from (thread channels only) - * @arg {Array} [options.permissionOverwrites] An array containing permission overwrite objects - * @arg {Number} [options.position] The sorting position of the channel - * @arg {Number} [options.rateLimitPerUser] The time in seconds a user has to wait before sending another message (does not affect bots or users with manageMessages/manageChannel permissions) (guild text and thread channels only) - * @arg {String?} [options.rtcRegion] The RTC region ID of the channel (automatic if `null`) (guild voice channels only) - * @arg {String} [options.topic] The topic of the channel (guild text channels only) - * @arg {Number} [options.userLimit] The channel user limit (guild voice channels only) - * @arg {Number} [options.videoQualityMode] The camera video quality mode of the channel (guild voice channels only). `1` is auto, `2` is 720p - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Edit the channel's properties + * @param {Object} options The properties to edit + * @param {Boolean} [options.archived] The archive status of the channel (thread channels only) + * @param {Array} [options.appliedTags] An array of applied tag IDs for the thread (available only in threads in thread-only channels) + * @param {Number} [options.autoArchiveDuration] The duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080 (thread channels only) + * @param {Array} [options.availableTags] Available tags for a forum channel + * @param {Number} [options.bitrate] The bitrate of the channel (guild voice channels only) + * @param {Number?} [options.defaultAutoArchiveDuration] The default duration of newly created threads in minutes to automatically archive the thread after inactivity (60, 1440, 4320, 10080) (guild text/news channels only) + * @param {Object} [options.defaultReactionEmoji] The emoji to show as the reaction button (forum channels only) + * @param {Number} [options.defaultSortOrder] The default thread sorting order + * @param {Number} [options.defaultThreadRateLimitPerUser] The initial ratelimit of the channel to use on newly created threads, in seconds. 0 means no ratelimit is enabled + * @param {Boolean} [options.invitable] Whether non-moderators can add other non-moderators to the channel (private thread channels only) + * @param {Boolean} [options.locked] The lock status of the channel (thread channels only) + * @param {String} [options.name] The name of the channel + * @param {Boolean} [options.nsfw] The nsfw status of the channel + * @param {Number?} [options.parentID] The ID of the parent channel category for this channel (guild text/voice channels only) or the channel ID where the thread originated from (thread channels only) + * @param {Array} [options.permissionOverwrites] An array containing permission overwrite objects + * @param {Number} [options.position] The sorting position of the channel + * @param {Number} [options.rateLimitPerUser] The time in seconds a user has to wait before sending another message (does not affect bots or users with manageMessages/manageChannel permissions) (guild text and thread channels only) + * @param {String?} [options.rtcRegion] The RTC region ID of the channel (automatic if `null`) (guild voice channels only) + * @param {String} [options.topic] The topic of the channel (guild text channels only) + * @param {Number} [options.userLimit] The channel user limit (guild voice channels only) + * @param {Number} [options.videoQualityMode] The camera video quality mode of the channel (guild voice channels only). `1` is auto, `2` is 720p + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ edit(options, reason) { return this.#client.editChannel.call(this.#client, this.id, options, reason); } /** - * Create a channel permission overwrite - * @arg {String} overwriteID The ID of the overwritten user or role - * @arg {BigInt | Number} allow The permissions number for allowed permissions - * @arg {BigInt | Number} deny The permissions number for denied permissions - * @arg {Number} type The object type of the overwrite, either 1 for "member" or 0 for "role" - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Create a channel permission overwrite + * @param {String} overwriteID The ID of the overwritten user or role + * @param {BigInt | Number} allow The permissions number for allowed permissions + * @param {BigInt | Number} deny The permissions number for denied permissions + * @param {Number} type The object type of the overwrite, either 1 for "member" or 0 for "role" + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ editPermission(overwriteID, allow, deny, type, reason) { return this.#client.editChannelPermission.call(this.#client, this.id, overwriteID, allow, deny, type, reason); } /** - * Edit the channel's position. Note that channel position numbers are lowest on top and highest at the bottom. - * @arg {Number} position The new position of the channel - * @arg {Object} [options] Additional options when editing position - * @arg {Boolean} [options.lockPermissions] Whether to sync the permissions with the new parent if moving to a new category - * @arg {String} [options.parentID] The new parent ID (category channel) for the channel that is moved - * @returns {Promise} - */ + * Edit the channel's position. Note that channel position numbers are lowest on top and highest at the bottom. + * @param {Number} position The new position of the channel + * @param {Object} [options] Additional options when editing position + * @param {Boolean} [options.lockPermissions] Whether to sync the permissions with the new parent if moving to a new category + * @param {String} [options.parentID] The new parent ID (category channel) for the channel that is moved + * @returns {Promise} + */ editPosition(position, options) { return this.#client.editChannelPosition.call(this.#client, this.id, position, options); } /** - * Get the channel-specific permissions of a member - * @arg {String | Member | Object} memberID The ID of the member or a Member object - * @returns {Permission} - */ + * Get the channel-specific permissions of a member + * @param {String | Member | Object} memberID The ID of the member or a Member object + * @returns {Permission} + */ permissionsOf(memberID) { const member = typeof memberID === "string" ? this.guild.members.get(memberID) : memberID; let permission = this.guild.permissionsOf(member).allow; diff --git a/lib/structures/GuildIntegration.js b/lib/structures/GuildIntegration.js index eb793eaf..9c9ce105 100644 --- a/lib/structures/GuildIntegration.js +++ b/lib/structures/GuildIntegration.js @@ -3,9 +3,9 @@ const Base = require("./Base"); /** -* Represents a guild integration -* @extends Base -*/ + * Represents a guild integration + * @extends Base + */ class GuildIntegration extends Base { /** * The ID of the integration @@ -126,9 +126,9 @@ class GuildIntegration extends Base { } /** - * Delete the guild integration - * @returns {Promise} - */ + * Delete the guild integration + * @returns {Promise} + */ delete() { return this.guild.shard.client.deleteGuildIntegration.call(this.guild.shard.client, this.guild.id, this.id); } diff --git a/lib/structures/GuildPreview.js b/lib/structures/GuildPreview.js index b981f022..9f0ac15f 100644 --- a/lib/structures/GuildPreview.js +++ b/lib/structures/GuildPreview.js @@ -4,9 +4,9 @@ const Base = require("./Base"); const Endpoints = require("../rest/Endpoints.js"); /** -* Represents a GuildPreview structure -* @extends Base -*/ + * Represents a GuildPreview structure + * @extends Base + */ class GuildPreview extends Base { #client; /** @@ -94,31 +94,31 @@ class GuildPreview extends Base { } /** - * Get the guild's splash with the given format and size - * @arg {String} [format] The filetype of the icon ("jpg", "jpeg", "png", "gif", or "webp") - * @arg {Number} [size] The size of the icon (any power of two between 16 and 4096) - * @returns {String?} - */ + * Get the guild's splash with the given format and size + * @param {String} [format] The filetype of the icon ("jpg", "jpeg", "png", "gif", or "webp") + * @param {Number} [size] The size of the icon (any power of two between 16 and 4096) + * @returns {String?} + */ dynamicDiscoverySplashURL(format, size) { return this.discoverySplash ? this.#client._formatImage(Endpoints.GUILD_DISCOVERY_SPLASH(this.id, this.discoverySplash), format, size) : null; } /** - * Get the guild's icon with the given format and size - * @arg {String} [format] The filetype of the icon ("jpg", "jpeg", "png", "gif", or "webp") - * @arg {Number} [size] The size of the icon (any power of two between 16 and 4096) - * @returns {String?} - */ + * Get the guild's icon with the given format and size + * @param {String} [format] The filetype of the icon ("jpg", "jpeg", "png", "gif", or "webp") + * @param {Number} [size] The size of the icon (any power of two between 16 and 4096) + * @returns {String?} + */ dynamicIconURL(format, size) { return this.icon ? this.#client._formatImage(Endpoints.GUILD_ICON(this.id, this.icon), format, size) : null; } /** - * Get the guild's splash with the given format and size - * @arg {String} [format] The filetype of the icon ("jpg", "jpeg", "png", "gif", or "webp") - * @arg {Number} [size] The size of the icon (any power of two between 16 and 4096) - * @returns {String?} - */ + * Get the guild's splash with the given format and size + * @param {String} [format] The filetype of the icon ("jpg", "jpeg", "png", "gif", or "webp") + * @param {Number} [size] The size of the icon (any power of two between 16 and 4096) + * @returns {String?} + */ dynamicSplashURL(format, size) { return this.splash ? this.#client._formatImage(Endpoints.GUILD_SPLASH(this.id, this.splash), format, size) : null; } diff --git a/lib/structures/GuildScheduledEvent.js b/lib/structures/GuildScheduledEvent.js index 91485f4c..054822dd 100644 --- a/lib/structures/GuildScheduledEvent.js +++ b/lib/structures/GuildScheduledEvent.js @@ -4,9 +4,9 @@ const Base = require("./Base"); const Endpoints = require("../rest/Endpoints"); /** -* Represents a guild scheduled event -* @extends Base -*/ + * Represents a guild scheduled event + * @extends Base + */ class GuildScheduledEvent extends Base { /** * The ID of the guild event @@ -137,43 +137,43 @@ class GuildScheduledEvent extends Base { } /** - * Delete this scheduled event - * @returns {Promise} - */ + * Delete this scheduled event + * @returns {Promise} + */ delete() { return this.#client.deleteGuildScheduledEvent.call(this.#client, this.guildID, this.id); } /** - * Edit this scheduled event - * @arg {Object} event The new guild scheduled event object - * @arg {String} [event.channelID] The channel ID of the event. If updating `entityType` to `3` (external), this **must** be set to `null` - * @arg {String} [event.description] The description of the event - * @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event. This is required if updating `entityType` to `3` (external) - * @arg {String} [event.entityMetadata.location] Location of the event. This is required if updating `entityType` to `3` (external) - * @arg {Number} [event.entityType] The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event - * @arg {String} [event.image] Base 64 encoded image for the event - * @arg {String} [event.name] The name of the event - * @arg {String} [event.privacyLevel] The privacy level of the event - * @arg {Date} [event.scheduledEndTime] The time when the scheduled event is scheduled to end. This is required if updating `entityType` to `3` (external) - * @arg {Date} [event.scheduledStartTime] The time the event will start - * @arg {Number} [event.status] The [status](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status) of the scheduled event - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Edit this scheduled event + * @param {Object} event The new guild scheduled event object + * @param {String} [event.channelID] The channel ID of the event. If updating `entityType` to `3` (external), this **must** be set to `null` + * @param {String} [event.description] The description of the event + * @param {Object} [event.entityMetadata] The entity metadata for the scheduled event. This is required if updating `entityType` to `3` (external) + * @param {String} [event.entityMetadata.location] Location of the event. This is required if updating `entityType` to `3` (external) + * @param {Number} [event.entityType] The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event + * @param {String} [event.image] Base 64 encoded image for the event + * @param {String} [event.name] The name of the event + * @param {String} [event.privacyLevel] The privacy level of the event + * @param {Date} [event.scheduledEndTime] The time when the scheduled event is scheduled to end. This is required if updating `entityType` to `3` (external) + * @param {Date} [event.scheduledStartTime] The time the event will start + * @param {Number} [event.status] The [status](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status) of the scheduled event + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ edit(event, reason) { return this.#client.editGuildScheduledEvent.call(this.#client, this.guildID, this.id, event, reason); } /** - * Get a list of users subscribed to the guild scheduled event - * @arg {Object} [options] Options for the request - * @arg {String} [options.after] Get users after this user ID. If `options.before` is provided, this will be ignored. Fetching users in between `before` and `after` is not supported - * @arg {String} [options.before] Get users before this user ID - * @arg {Number} [options.limit=100] The number of users to get (max 100). Pagination will only work if one of `options.after` or `options.after` is also provided - * @arg {Boolean} [options.withMember] Include guild member data - * @returns {Promise>} - */ + * Get a list of users subscribed to the guild scheduled event + * @param {Object} [options] Options for the request + * @param {String} [options.after] Get users after this user ID. If `options.before` is provided, this will be ignored. Fetching users in between `before` and `after` is not supported + * @param {String} [options.before] Get users before this user ID + * @param {Number} [options.limit=100] The number of users to get (max 100). Pagination will only work if one of `options.after` or `options.after` is also provided + * @param {Boolean} [options.withMember] Include guild member data + * @returns {Promise>} + */ getUsers(options) { return this.#client.getGuildScheduledEventUsers.call(this.#client, this.guild.id, this.id, options); } diff --git a/lib/structures/GuildTemplate.js b/lib/structures/GuildTemplate.js index 93e87a2e..0acc7686 100644 --- a/lib/structures/GuildTemplate.js +++ b/lib/structures/GuildTemplate.js @@ -2,8 +2,8 @@ const Base = require("./Base"); const Guild = require("./Guild"); /** -* Represents a guild template -*/ + * Represents a guild template + */ class GuildTemplate { #client; constructor(data, client) { @@ -61,38 +61,38 @@ class GuildTemplate { } /** - * Create a guild based on this template. This can only be used with bots in less than 10 guilds - * @arg {String} name The name of the guild - * @arg {String} [icon] The 128x128 icon as a base64 data URI - * @returns {Promise} - */ + * Create a guild based on this template. This can only be used with bots in less than 10 guilds + * @param {String} name The name of the guild + * @param {String} [icon] The 128x128 icon as a base64 data URI + * @returns {Promise} + */ createGuild(name, icon) { return this.#client.createGuildFromTemplate.call(this.#client, this.code, name, icon); } /** - * Delete this template - * @returns {Promise} - */ + * Delete this template + * @returns {Promise} + */ delete() { return this.#client.deleteGuildTemplate.call(this.#client, this.sourceGuild.id, this.code); } /** - * Edit this template - * @arg {Object} options The properties to edit - * @arg {String} [options.name] The name of the template - * @arg {String?} [options.description] The description for the template. Set to `null` to remove the description - * @returns {Promise} - */ + * Edit this template + * @param {Object} options The properties to edit + * @param {String} [options.name] The name of the template + * @param {String?} [options.description] The description for the template. Set to `null` to remove the description + * @returns {Promise} + */ edit(options) { return this.#client.editGuildTemplate.call(this.#client, this.sourceGuild.id, this.code, options); } /** - * Force this template to sync to the guild's current state - * @returns {Promise} - */ + * Force this template to sync to the guild's current state + * @returns {Promise} + */ sync() { return this.#client.syncGuildTemplate.call(this.#client, this.sourceGuild.id, this.code); } diff --git a/lib/structures/Interaction.js b/lib/structures/Interaction.js index 5f8c6321..3b368ea3 100644 --- a/lib/structures/Interaction.js +++ b/lib/structures/Interaction.js @@ -6,9 +6,9 @@ const Member = require("./Member"); const Permission = require("./Permission"); /** -* Represents an interaction. You also probably want to look at AutocompleteInteraction, CommandInteraction, ComponentInteraction, and ModalSubmitInteraction. -* @extends Base -*/ + * Represents an interaction. You also probably want to look at AutocompleteInteraction, CommandInteraction, ComponentInteraction, and ModalSubmitInteraction. + * @extends Base + */ class Interaction extends Base { /** * The ID of the interaction @@ -160,7 +160,7 @@ class Interaction extends Base { module.exports = Interaction; // Circular import -const CommandInteraction = require("./CommandInteraction"); -const ComponentInteraction = require("./ComponentInteraction"); +const CommandInteraction = require("./CommandInteraction"); +const ComponentInteraction = require("./ComponentInteraction"); const AutocompleteInteraction = require("./AutocompleteInteraction"); -const ModalSubmitInteraction = require("./ModalSubmitInteraction.js"); +const ModalSubmitInteraction = require("./ModalSubmitInteraction.js"); diff --git a/lib/structures/Invite.js b/lib/structures/Invite.js index c6767bda..90e21897 100644 --- a/lib/structures/Invite.js +++ b/lib/structures/Invite.js @@ -5,9 +5,9 @@ const Guild = require("./Guild"); const GuildScheduledEvent = require("./GuildScheduledEvent"); /** -* Represents an invite. Some properties are only available when fetching invites from channels, which requires the Manage Channel permission. -* @extends Base -*/ + * Represents an invite. Some properties are only available when fetching invites from channels, which requires the Manage Channel permission. + * @extends Base + */ class Invite extends Base { /** * Invites don't have an ID. @@ -154,10 +154,10 @@ class Invite extends Base { } /** - * Delete the invite - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Delete the invite + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ delete(reason) { return this.#client.deleteInvite.call(this.#client, this.code, reason); } diff --git a/lib/structures/Member.js b/lib/structures/Member.js index 488787db..5db1b72b 100644 --- a/lib/structures/Member.js +++ b/lib/structures/Member.js @@ -6,9 +6,9 @@ const User = require("./User"); const VoiceState = require("./VoiceState"); /** -* Represents a server member -* @extends Base -*/ + * Represents a server member + * @extends Base + */ class Member extends Base { /** * The ID of the member @@ -89,7 +89,7 @@ class Member extends Base { * Timestamp of when the member joined the guild * @type {Number?} */ - this.joinedAt = data.joined_at ? Date.parse(data.joined_at) : null; + this.joinedAt = data.joined_at ? Date.parse(data.joined_at) : null; } if(data.client_status !== undefined) { /** @@ -267,7 +267,7 @@ class Member extends Base { * The URL of the user's avatar (always a JPG) * @type {String} */ - get staticAvatarURL(){ + get staticAvatarURL() { return this.user.staticAvatarURL; } @@ -298,81 +298,79 @@ class Member extends Base { } /** - * Add a role to the guild member - * @arg {String} roleID The ID of the role - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Add a role to the guild member + * @param {String} roleID The ID of the role + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ addRole(roleID, reason) { return this.guild.shard.client.addGuildMemberRole.call(this.guild.shard.client, this.guild.id, this.id, roleID, reason); } /** - * Ban the user from the guild - * @arg {Number} [options.deleteMessageSeconds=0] Number of seconds to delete messages for, between 0 and 604,800 inclusive - * @arg {String} [options.reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Ban the user from the guild + * @param {Number} [options.deleteMessageSeconds=0] Number of seconds to delete messages for, between 0 and 604,800 inclusive + * @param {String} [options.reason] The reason to be displayed in audit logs + * @returns {Promise} + */ ban(options) { return this.guild.shard.client.banGuildMember.call(this.guild.shard.client, this.guild.id, this.id, options); } /** - * Get the member's avatar with the given format and size - * @arg {String} [format] The filetype of the avatar ("jpg", "jpeg", "png", "gif", or "webp") - * @arg {Number} [size] The size of the avatar (any power of two between 16 and 4096) - * @returns {String} - */ + * Get the member's avatar with the given format and size + * @param {String} [format] The filetype of the avatar ("jpg", "jpeg", "png", "gif", or "webp") + * @param {Number} [size] The size of the avatar (any power of two between 16 and 4096) + * @returns {String} + */ dynamicAvatarURL(format, size) { if(!this.avatar) { return this.user.dynamicAvatarURL(format, size); } return this.guild.shard.client._formatImage(Endpoints.GUILD_AVATAR(this.guild.id, this.id, this.avatar), format, size); } + /** - * Edit the guild member - * @arg {Object} options The properties to edit - * @arg {String?} [options.channelID] The ID of the voice channel to move the member to (must be in voice). Set to `null` to disconnect the member - * @arg {Date?} [options.communicationDisabledUntil] When the user's timeout should expire. Set to `null` to instantly remove timeout - * @arg {Boolean} [options.deaf] Server deafen the user - * @arg {Number} [options.flags] The guild member flag bit set - * @arg {Boolean} [options.mute] Server mute the user - * @arg {String} [options.nick] Set the user's server nickname, "" to remove - * @arg {Array} [options.roles] The array of role IDs the user should have - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Edit the guild member + * @param {Object} options The properties to edit + * @param {String?} [options.channelID] The ID of the voice channel to move the member to (must be in voice). Set to `null` to disconnect the member + * @param {Date?} [options.communicationDisabledUntil] When the user's timeout should expire. Set to `null` to instantly remove timeout + * @param {Boolean} [options.deaf] Server deafen the user + * @param {Number} [options.flags] The guild member flag bit set + * @param {Boolean} [options.mute] Server mute the user + * @param {String} [options.nick] Set the user's server nickname, "" to remove + * @param {Array} [options.roles] The array of role IDs the user should have + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ edit(options, reason) { return this.guild.shard.client.editGuildMember.call(this.guild.shard.client, this.guild.id, this.id, options, reason); } - - - /** - * Kick the member from the guild - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Kick the member from the guild + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ kick(reason) { return this.guild.shard.client.kickGuildMember.call(this.guild.shard.client, this.guild.id, this.id, reason); } /** - * Remove a role from the guild member - * @arg {String} roleID The ID of the role - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Remove a role from the guild member + * @param {String} roleID The ID of the role + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ removeRole(roleID, reason) { return this.guild.shard.client.removeGuildMemberRole.call(this.guild.shard.client, this.guild.id, this.id, roleID, reason); } /** - * Unban the user from the guild - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Unban the user from the guild + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ unban(reason) { return this.guild.shard.client.unbanGuildMember.call(this.guild.shard.client, this.guild.id, this.id, reason); } diff --git a/lib/structures/Message.js b/lib/structures/Message.js index 7c6cb65d..95a2eb90 100644 --- a/lib/structures/Message.js +++ b/lib/structures/Message.js @@ -8,9 +8,9 @@ const Attachment = require("./Attachment"); const Collection = require("../util/Collection"); /** -* Represents a message -* @extends Base -*/ + * Represents a message + * @extends Base + */ class Message extends Base { /** * Timestamp of message creation @@ -551,10 +551,10 @@ class Message extends Base { } /** - * Add a reaction to a message - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @returns {Promise} - */ + * Add a reaction to a message + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @returns {Promise} + */ addReaction(reaction) { if(this.flags & MessageFlags.EPHEMERAL) { throw new Error("Ephemeral messages cannot have reactions"); @@ -563,12 +563,12 @@ class Message extends Base { } /** - * Create a thread with this message - * @arg {Object} options The thread options - * @arg {Number} options.autoArchiveDuration Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080 - * @arg {String} options.name The thread channel name - * @returns {Promise} - */ + * Create a thread with this message + * @param {Object} options The thread options + * @param {Number} options.autoArchiveDuration Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080 + * @param {String} options.name The thread channel name + * @returns {Promise} + */ createThreadWithMessage(options) { return this.#client.createThreadWithMessage.call(this.#client, this.channel.id, this.id, options); } @@ -585,10 +585,10 @@ class Message extends Base { } /** - * Delete the message - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Delete the message + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ delete(reason) { if(this.flags & MessageFlags.EPHEMERAL) { throw new Error("Ephemeral messages cannot be deleted"); @@ -597,10 +597,10 @@ class Message extends Base { } /** - * Delete the message as a webhook. May fail if the message is created in an uncached thread. - * @arg {String} token The token of the webhook - * @returns {Promise} - */ + * Delete the message as a webhook. May fail if the message is created in an uncached thread. + * @param {String} token The token of the webhook + * @returns {Promise} + */ deleteWebhook(token) { if(!this.webhookID) { throw new Error("Message is not a webhook"); @@ -610,27 +610,28 @@ class Message extends Base { } return this.#client.deleteWebhookMessage.call(this.#client, this.webhookID, token, this.id, [ChannelTypes.ANNOUNCEMENT_THREAD, ChannelTypes.PUBLIC_THREAD, ChannelTypes.PRIVATE_THREAD].includes(this.channel.type) - ? this.channel.id : undefined); + ? this.channel.id + : undefined); } /** - * Edit the message - * @arg {String | Array | Object} content A string, array of strings, or object. If an object is passed: - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) - * @arg {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {Number} [content.flags] A number representing the flags to apply to the message. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list - * @returns {Promise} - */ + * Edit the message + * @param {String | Array | Object} content A string, array of strings, or object. If an object is passed: + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow + * @param {Array} [content.attachments] The files to attach to the message + * @param {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) + * @param {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {Number} [content.flags] A number representing the flags to apply to the message. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list + * @returns {Promise} + */ edit(content) { if(this.flags & MessageFlags.EPHEMERAL) { throw new Error("Ephemeral messages cannot be edited via this method"); @@ -639,24 +640,24 @@ class Message extends Base { } /** - * Edit the message as a webhook - * @arg {String} token The token of the webhook - * @arg {Object} options Webhook message edit options - * @arg {Object} [options.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [options.allowedMentions.everyone] Whether or not to allow @everyone/@here - * @arg {Boolean} [options.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to - * @arg {Boolean | Array} [options.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow - * @arg {Boolean | Array} [options.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) - * @arg {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [options.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [options.content] A content string - * @arg {Array} [options.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @returns {Promise} - */ + * Edit the message as a webhook + * @param {String} token The token of the webhook + * @param {Object} options Webhook message edit options + * @param {Object} [options.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [options.allowedMentions.everyone] Whether or not to allow @everyone/@here + * @param {Boolean} [options.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to + * @param {Boolean | Array} [options.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow + * @param {Boolean | Array} [options.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow + * @param {Array} [content.attachments] The files to attach to the message + * @param {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) + * @param {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [options.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [options.content] A content string + * @param {Array} [options.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @returns {Promise} + */ editWebhook(token, options) { if(!this.webhookID) { throw new Error("Message is not a webhook"); @@ -685,14 +686,14 @@ class Message extends Base { } /** - * Get a list of users who reacted with a specific reaction - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @arg {Object} [options] Options for the request. - * @arg {Number} [options.limit=100] The maximum number of users to get - * @arg {String} [options.after] Get users after this user ID - * @arg {Number} [options.type=0] The type of reaction to get - * @returns {Promise>} - */ + * Get a list of users who reacted with a specific reaction + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @param {Object} [options] Options for the request. + * @param {Number} [options.limit=100] The maximum number of users to get + * @param {String} [options.after] Get users after this user ID + * @param {Number} [options.type=0] The type of reaction to get + * @returns {Promise>} + */ getReaction(reaction, options) { if(this.flags & MessageFlags.EPHEMERAL) { throw new Error("Ephemeral messages cannot have reactions"); @@ -701,9 +702,9 @@ class Message extends Base { } /** - * Pin the message - * @returns {Promise} - */ + * Pin the message + * @returns {Promise} + */ pin() { if(this.flags & MessageFlags.EPHEMERAL) { throw new Error("Ephemeral messages cannot be pinned"); @@ -712,11 +713,11 @@ class Message extends Base { } /** - * Remove a reaction from a message - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @arg {String} [userID="@me"] The ID of the user to remove the reaction for - * @returns {Promise} - */ + * Remove a reaction from a message + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @param {String} [userID="@me"] The ID of the user to remove the reaction for + * @returns {Promise} + */ removeReaction(reaction, userID) { if(this.flags & MessageFlags.EPHEMERAL) { throw new Error("Ephemeral messages cannot have reactions"); @@ -725,10 +726,10 @@ class Message extends Base { } /** - * Remove all reactions from a message for a single emoji - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @returns {Promise} - */ + * Remove all reactions from a message for a single emoji + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @returns {Promise} + */ removeReactionEmoji(reaction) { if(this.flags & MessageFlags.EPHEMERAL) { throw new Error("Ephemeral messages cannot have reactions"); @@ -737,9 +738,9 @@ class Message extends Base { } /** - * Remove all reactions from a message - * @returns {Promise} - */ + * Remove all reactions from a message + * @returns {Promise} + */ removeReactions() { if(this.flags & MessageFlags.EPHEMERAL) { throw new Error("Ephemeral messages cannot have reactions"); @@ -748,9 +749,9 @@ class Message extends Base { } /** - * Unpin the message - * @returns {Promise} - */ + * Unpin the message + * @returns {Promise} + */ unpin() { if(this.flags & MessageFlags.EPHEMERAL) { throw new Error("Ephemeral messages cannot be pinned"); diff --git a/lib/structures/ModalSubmitInteraction.js b/lib/structures/ModalSubmitInteraction.js index a8eb904b..4a7e03a5 100644 --- a/lib/structures/ModalSubmitInteraction.js +++ b/lib/structures/ModalSubmitInteraction.js @@ -5,9 +5,9 @@ const Interaction = require("./Interaction"); const {InteractionResponseTypes} = require("../Constants"); /** -* Represents a modal submit interaction. -* @extends Interaction -*/ + * Represents a modal submit interaction. + * @extends Interaction + */ class ModalSubmitInteraction extends Interaction { /** * @override @@ -26,32 +26,32 @@ class ModalSubmitInteraction extends Interaction { } /** - * Acknowledges the interaction with a defer message update response - * @returns {Promise} - */ + * Acknowledges the interaction with a defer message update response + * @returns {Promise} + */ async acknowledge() { return this.deferUpdate(); } /** - * Respond to the interaction with a followup message - * @arg {String | Object} content A string or object. If an object is passed: - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {Buffer} content.attachments[].file A buffer containing file data - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Array} [options.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {Number} [content.flags] 64 for Ephemeral - * @arg {Object} [content.poll] A poll object. See [Discord's Documentation](https://discord.com/developers/docs/resources/poll#poll-create-request-object-poll-create-request-object-structure) for object structure - * @arg {Boolean} [content.tts] Set the message TTS flag - * @returns {Promise} - */ + * Respond to the interaction with a followup message + * @param {String | Object} content A string or object. If an object is passed: + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow + * @param {Array} [content.attachments] The files to attach to the message + * @param {Buffer} content.attachments[].file A buffer containing file data + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Array} [options.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {Number} [content.flags] 64 for Ephemeral + * @param {Object} [content.poll] A poll object. See [Discord's Documentation](https://discord.com/developers/docs/resources/poll#poll-create-request-object-poll-create-request-object-structure) for object structure + * @param {Boolean} [content.tts] Set the message TTS flag + * @returns {Promise} + */ async createFollowup(content) { if(this.acknowledged === false) { throw new Error("createFollowup cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, or editParent first."); @@ -69,24 +69,24 @@ class ModalSubmitInteraction extends Interaction { } /** - * Acknowledges the interaction with a message. If already acknowledged runs createFollowup - * @arg {String | Object} content A string or object. If an object is passed: - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {Buffer} content.attachments[].file A buffer containing file data - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {Boolean} [content.flags] 64 for Ephemeral - * @arg {Object} [content.poll] A poll object. See [Discord's Documentation](https://discord.com/developers/docs/resources/poll#poll-create-request-object-poll-create-request-object-structure) for object structure - * @arg {Boolean} [content.tts] Set the message TTS flag - * @returns {Promise} - */ + * Acknowledges the interaction with a message. If already acknowledged runs createFollowup + * @param {String | Object} content A string or object. If an object is passed: + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow + * @param {Array} [content.attachments] The files to attach to the message + * @param {Buffer} content.attachments[].file A buffer containing file data + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {Boolean} [content.flags] 64 for Ephemeral + * @param {Object} [content.poll] A poll object. See [Discord's Documentation](https://discord.com/developers/docs/resources/poll#poll-create-request-object-poll-create-request-object-structure) for object structure + * @param {Boolean} [content.tts] Set the message TTS flag + * @returns {Promise} + */ async createMessage(content) { if(this.acknowledged === true) { return this.createFollowup(content); @@ -114,11 +114,11 @@ class ModalSubmitInteraction extends Interaction { } /** - * Acknowledges the interaction with a defer response - * Note: You can **not** use more than 1 initial interaction response per interaction - * @arg {Number} [flags] 64 for Ephemeral - * @returns {Promise} - */ + * Acknowledges the interaction with a defer response + * Note: You can **not** use more than 1 initial interaction response per interaction + * @param {Number} [flags] 64 for Ephemeral + * @returns {Promise} + */ async defer(flags) { if(this.acknowledged === true) { throw new Error("You have already acknowledged this interaction."); @@ -132,10 +132,10 @@ class ModalSubmitInteraction extends Interaction { } /** - * Acknowledges the interaction with a defer message update response - * Note: You can **not** use more than 1 initial interaction response per interaction - * @returns {Promise} - */ + * Acknowledges the interaction with a defer message update response + * Note: You can **not** use more than 1 initial interaction response per interaction + * @returns {Promise} + */ async deferUpdate() { if(this.acknowledged === true) { throw new Error("You have already acknowledged this interaction."); @@ -146,10 +146,10 @@ class ModalSubmitInteraction extends Interaction { } /** - * Delete a message - * @arg {String} messageID the id of the message to delete, or "@original" for the original response - * @returns {Promise} - */ + * Delete a message + * @param {String} messageID the id of the message to delete, or "@original" for the original response + * @returns {Promise} + */ async deleteMessage(messageID) { if(this.acknowledged === false) { throw new Error("deleteMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, or editParent first."); @@ -158,10 +158,10 @@ class ModalSubmitInteraction extends Interaction { } /** - * Delete the parent message - * Warning: Will error with ephemeral messages - * @returns {Promise} - */ + * Delete the parent message + * Warning: Will error with ephemeral messages + * @returns {Promise} + */ async deleteOriginalMessage() { if(this.acknowledged === false) { throw new Error("deleteOriginalMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, or editParent first."); @@ -170,24 +170,24 @@ class ModalSubmitInteraction extends Interaction { } /** - * Edit a message - * @arg {String} messageID the id of the message to edit, or "@original" for the original response - * @arg {Object} content Interaction message edit options - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here - * @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) - * @arg {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @returns {Promise} - */ + * Edit a message + * @param {String} messageID the id of the message to edit, or "@original" for the original response + * @param {Object} content Interaction message edit options + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here + * @param {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow + * @param {Array} [content.attachments] The files to attach to the message + * @param {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) + * @param {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @returns {Promise} + */ async editMessage(messageID, content) { if(this.acknowledged === false) { throw new Error("editMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, or editParent first."); @@ -205,23 +205,23 @@ class ModalSubmitInteraction extends Interaction { } /** - * Edit the parent message - * @arg {Object} content Interaction message edit options - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here - * @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) - * @arg {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @returns {Promise} - */ + * Edit the parent message + * @param {Object} content Interaction message edit options + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here + * @param {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow + * @param {Array} [content.attachments] The files to attach to the message + * @param {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) + * @param {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @returns {Promise} + */ async editOriginalMessage(content) { if(this.acknowledged === false) { throw new Error("editOriginalMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, or editParent first."); @@ -239,26 +239,26 @@ class ModalSubmitInteraction extends Interaction { } /** - * Acknowledges the interaction by editing the parent message. If already acknowledged runs editOriginalMessage - * Warning: Will error with ephemeral messages - * @arg {String | Object} content What to edit the message with - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here - * @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) - * @arg {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {Boolean} [content.flags] 64 for Ephemeral - * @arg {Boolean} [content.tts] Set the message TTS flag - * @returns {Promise} - */ + * Acknowledges the interaction by editing the parent message. If already acknowledged runs editOriginalMessage + * Warning: Will error with ephemeral messages + * @param {String | Object} content What to edit the message with + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here + * @param {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow + * @param {Array} [content.attachments] The files to attach to the message + * @param {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) + * @param {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {Boolean} [content.flags] 64 for Ephemeral + * @param {Boolean} [content.tts] Set the message TTS flag + * @returns {Promise} + */ async editParent(content) { if(this.acknowledged === true) { return this.editOriginalMessage(content); @@ -286,17 +286,16 @@ class ModalSubmitInteraction extends Interaction { } /** - * Get the parent message - * Warning: Will error with ephemeral messages - * @returns {Promise} - */ + * Get the parent message + * Warning: Will error with ephemeral messages + * @returns {Promise} + */ async getOriginalMessage() { if(this.acknowledged === false) { throw new Error("getOriginalMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, or editParent first."); } return this.#client.getWebhookMessage.call(this.#client, this.applicationID, this.token, "@original"); } - } module.exports = ModalSubmitInteraction; diff --git a/lib/structures/NewsChannel.js b/lib/structures/NewsChannel.js index 169d2567..ab9fa155 100644 --- a/lib/structures/NewsChannel.js +++ b/lib/structures/NewsChannel.js @@ -3,9 +3,9 @@ const TextChannel = require("./TextChannel"); /** -* Represents a guild news channel. -* @extends TextChannel -*/ + * Represents a guild news channel. + * @extends TextChannel + */ class NewsChannel extends TextChannel { #client; constructor(data, client, messageLimit) { @@ -16,7 +16,7 @@ class NewsChannel extends TextChannel { /** * Crosspost (publish) a message to subscribed channels - * @arg {String} messageID The ID of the message + * @param {String} messageID The ID of the message * @returns {Promise} */ crosspostMessage(messageID) { @@ -25,8 +25,8 @@ class NewsChannel extends TextChannel { /** * Follow this channel in another channel. This creates a webhook in the target channel - * @arg {String} webhookChannelID The ID of the target channel - * @arg {String} [reason] The reason to be displayed in audit logs + * @param {String} webhookChannelID The ID of the target channel + * @param {String} [reason] The reason to be displayed in audit logs * @returns {Object} An object containing this channel's ID and the new webhook's ID */ follow(webhookChannelID, reason) { diff --git a/lib/structures/NewsThreadChannel.js b/lib/structures/NewsThreadChannel.js index c1008739..bcc406b1 100644 --- a/lib/structures/NewsThreadChannel.js +++ b/lib/structures/NewsThreadChannel.js @@ -3,9 +3,9 @@ const ThreadChannel = require("./ThreadChannel"); /** -* Represents a news thread channel. -* @extends ThreadChannel -*/ + * Represents a news thread channel. + * @extends ThreadChannel + */ class NewsThreadChannel extends ThreadChannel { constructor(data, client, messageLimit) { super(data, client, messageLimit); diff --git a/lib/structures/Permission.js b/lib/structures/Permission.js index c0d3abdd..a88f82b3 100644 --- a/lib/structures/Permission.js +++ b/lib/structures/Permission.js @@ -4,8 +4,8 @@ const Base = require("./Base"); const {Permissions} = require("../Constants"); /** -* Represents a calculated permissions number -*/ + * Represents a calculated permissions number + */ class Permission extends Base { #json; constructor(allow, deny = 0) { @@ -56,10 +56,10 @@ class Permission extends Base { } /** - * Check if this permission allows a specific permission - * @arg {String | BigInt} permission The name of the permission, or bit of permissions. [A full list of permission nodes can be found on the docs reference page](/Eris/docs/reference). Pass a BigInt if you want to check multiple permissions. - * @returns {Boolean} Whether the permission allows the specified permission - */ + * Check if this permission allows a specific permission + * @param {String | BigInt} permission The name of the permission, or bit of permissions. [A full list of permission nodes can be found on the docs reference page](/Eris/docs/reference). Pass a BigInt if you want to check multiple permissions. + * @returns {Boolean} Whether the permission allows the specified permission + */ has(permission) { if(typeof permission === "bigint") { return (this.allow & permission) === permission; diff --git a/lib/structures/PermissionOverwrite.js b/lib/structures/PermissionOverwrite.js index 56d05116..8884abaa 100644 --- a/lib/structures/PermissionOverwrite.js +++ b/lib/structures/PermissionOverwrite.js @@ -3,9 +3,9 @@ const Permission = require("./Permission"); /** -* Represents a permission overwrite -* @extends Permission -*/ + * Represents a permission overwrite + * @extends Permission + */ class PermissionOverwrite extends Permission { constructor(data) { super(data.allow, data.deny); diff --git a/lib/structures/PingInteraction.js b/lib/structures/PingInteraction.js index dc3277eb..756560c9 100644 --- a/lib/structures/PingInteraction.js +++ b/lib/structures/PingInteraction.js @@ -4,9 +4,9 @@ const Interaction = require("./Interaction"); const {InteractionResponseTypes} = require("../Constants"); /** -* Represents a ping interaction. See Interaction for more properties. -* @extends Interaction -*/ + * Represents a ping interaction. See Interaction for more properties. + * @extends Interaction + */ class PingInteraction extends Interaction { #client; constructor(data, client) { @@ -15,19 +15,19 @@ class PingInteraction extends Interaction { } /** - * Acknowledges the ping interaction with a pong response. - * Note: You can **not** use more than 1 initial interaction response per interaction. - * @returns {Promise} - */ + * Acknowledges the ping interaction with a pong response. + * Note: You can **not** use more than 1 initial interaction response per interaction. + * @returns {Promise} + */ acknowledge() { return this.pong(); } /** - * Acknowledges the ping interaction with a pong response. - * Note: You can **not** use more than 1 initial interaction response per interaction. - * @returns {Promise} - */ + * Acknowledges the ping interaction with a pong response. + * Note: You can **not** use more than 1 initial interaction response per interaction. + * @returns {Promise} + */ pong() { if(this.acknowledged === true) { throw new Error("You have already acknowledged this interaction."); @@ -36,7 +36,6 @@ class PingInteraction extends Interaction { type: InteractionResponseTypes.PONG }).then(() => this.update()); } - } module.exports = PingInteraction; diff --git a/lib/structures/PrivateChannel.js b/lib/structures/PrivateChannel.js index 27888d5c..dce00141 100644 --- a/lib/structures/PrivateChannel.js +++ b/lib/structures/PrivateChannel.js @@ -7,9 +7,9 @@ const {ChannelTypes} = require("../Constants"); const User = require("./User"); /** -* Represents a private channel. -* @extends Channel -*/ + * Represents a private channel. + * @extends Channel + */ class PrivateChannel extends Channel { #client; constructor(data, client) { @@ -37,172 +37,172 @@ class PrivateChannel extends Channel { } /** - * Add a reaction to a message - * @arg {String} messageID The ID of the message - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @returns {Promise} - */ + * Add a reaction to a message + * @param {String} messageID The ID of the message + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @returns {Promise} + */ addMessageReaction(messageID, reaction) { return this.#client.addMessageReaction.call(this.#client, this.id, messageID, reaction); } /** - * Create a message in a text channel - * @arg {String | Object} content A string or object. If an object is passed: - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. - * @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {Buffer} content.attachments[].file A buffer containing file data - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Boolean} [content.enforceNonce] If set and nonce is present, check the message for uniqueness in the past few minutes - * @arg {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {Object} [content.messageReference] The message reference, used when replying to messages - * @arg {String} [content.messageReference.channelID] The channel ID of the referenced message - * @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message - * @arg {String} [content.messageReference.guildID] The guild ID of the referenced message - * @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message - * @arg {String | Number} [content.nonce] A value that can be used to check if the message was sent - * @arg {Object} [content.poll] A poll object. See [Discord's Documentation](https://discord.com/developers/docs/resources/poll#poll-create-request-object-poll-create-request-object-structure) for object structure - * @arg {Array} [content.stickerIDs] An array of IDs corresponding to stickers to send - * @arg {Boolean} [content.tts] Set the message TTS flag - * @returns {Promise} - */ + * Create a message in a text channel + * @param {String | Object} content A string or object. If an object is passed: + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. + * @param {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. + * @param {Array} [content.attachments] The files to attach to the message + * @param {Buffer} content.attachments[].file A buffer containing file data + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Boolean} [content.enforceNonce] If set and nonce is present, check the message for uniqueness in the past few minutes + * @param {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {Object} [content.messageReference] The message reference, used when replying to messages + * @param {String} [content.messageReference.channelID] The channel ID of the referenced message + * @param {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message + * @param {String} [content.messageReference.guildID] The guild ID of the referenced message + * @param {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message + * @param {String | Number} [content.nonce] A value that can be used to check if the message was sent + * @param {Object} [content.poll] A poll object. See [Discord's Documentation](https://discord.com/developers/docs/resources/poll#poll-create-request-object-poll-create-request-object-structure) for object structure + * @param {Array} [content.stickerIDs] An array of IDs corresponding to stickers to send + * @param {Boolean} [content.tts] Set the message TTS flag + * @returns {Promise} + */ createMessage(content) { return this.#client.createMessage.call(this.#client, this.id, content); } /** - * Delete a message - * @arg {String} messageID The ID of the message - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Delete a message + * @param {String} messageID The ID of the message + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ deleteMessage(messageID, reason) { return this.#client.deleteMessage.call(this.#client, this.id, messageID, reason); } /** - * Edit a message - * @arg {String} messageID The ID of the message - * @arg {String | Array | Object} content A string, array of strings, or object. If an object is passed: - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) - * @arg {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {Number} [content.flags] A number representing the flags to apply to the message. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for flags reference - * @returns {Promise} - */ + * Edit a message + * @param {String} messageID The ID of the message + * @param {String | Array | Object} content A string, array of strings, or object. If an object is passed: + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. + * @param {Array} [content.attachments] The files to attach to the message + * @param {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) + * @param {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {Number} [content.flags] A number representing the flags to apply to the message. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for flags reference + * @returns {Promise} + */ editMessage(messageID, content) { return this.#client.editMessage.call(this.#client, this.id, messageID, content); } /** - * Get a previous message in a text channel - * @arg {String} messageID The ID of the message - * @returns {Promise} - */ + * Get a previous message in a text channel + * @param {String} messageID The ID of the message + * @returns {Promise} + */ getMessage(messageID) { return this.#client.getMessage.call(this.#client, this.id, messageID); } /** - * Get a list of users who reacted with a specific reaction - * @arg {String} messageID The ID of the message - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @arg {Object} [options] Options for the request. - * @arg {Number} [options.limit=100] The maximum number of users to get - * @arg {String} [options.after] Get users after this user ID - * @arg {Number} [options.type=0] The type of reaction to get - * @returns {Promise>} - */ + * Get a list of users who reacted with a specific reaction + * @param {String} messageID The ID of the message + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @param {Object} [options] Options for the request. + * @param {Number} [options.limit=100] The maximum number of users to get + * @param {String} [options.after] Get users after this user ID + * @param {Number} [options.type=0] The type of reaction to get + * @returns {Promise>} + */ getMessageReaction(messageID, reaction, options) { return this.#client.getMessageReaction.call(this.#client, this.id, messageID, reaction, options); } /** - * Get a previous message in a text channel - * @arg {Object} [options] Options for the request. - * @arg {String} [options.after] Get messages after this message ID - * @arg {String} [options.around] Get messages around this message ID (does not work with limit > 100) - * @arg {String} [options.before] Get messages before this message ID - * @arg {Number} [options.limit=50] The max number of messages to get - * @returns {Promise>} - */ + * Get a previous message in a text channel + * @param {Object} [options] Options for the request. + * @param {String} [options.after] Get messages after this message ID + * @param {String} [options.around] Get messages around this message ID (does not work with limit > 100) + * @param {String} [options.before] Get messages before this message ID + * @param {Number} [options.limit=50] The max number of messages to get + * @returns {Promise>} + */ getMessages(options) { return this.#client.getMessages.call(this.#client, this.id, options); } /** - * Get all the pins in a text channel - * @returns {Promise>} - */ + * Get all the pins in a text channel + * @returns {Promise>} + */ getPins() { return this.#client.getPins.call(this.#client, this.id); } /** - * Leave the channel - * @returns {Promise} - */ + * Leave the channel + * @returns {Promise} + */ leave() { return this.#client.deleteChannel.call(this.#client, this.id); } /** - * Pin a message - * @arg {String} messageID The ID of the message - * @returns {Promise} - */ + * Pin a message + * @param {String} messageID The ID of the message + * @returns {Promise} + */ pinMessage(messageID) { return this.#client.pinMessage.call(this.#client, this.id, messageID); } /** - * Remove a reaction from a message - * @arg {String} messageID The ID of the message - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @returns {Promise} - */ + * Remove a reaction from a message + * @param {String} messageID The ID of the message + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @returns {Promise} + */ removeMessageReaction(messageID, reaction) { return this.#client.removeMessageReaction.call(this.#client, this.id, messageID, reaction); } /** - * Send typing status in a text channel - * @returns {Promise} - */ + * Send typing status in a text channel + * @returns {Promise} + */ sendTyping() { return this.#client.sendChannelTyping.call(this.#client, this.id); } /** - * Unpin a message - * @arg {String} messageID The ID of the message - * @returns {Promise} - */ + * Unpin a message + * @param {String} messageID The ID of the message + * @returns {Promise} + */ unpinMessage(messageID) { return this.#client.unpinMessage.call(this.#client, this.id, messageID); } /** - * Un-send a message. You're welcome Programmix - * @arg {String} messageID The ID of the message - * @returns {Promise} - */ + * Un-send a message. You're welcome Programmix + * @param {String} messageID The ID of the message + * @returns {Promise} + */ unsendMessage(messageID) { return this.#client.deleteMessage.call(this.#client, this.id, messageID); } diff --git a/lib/structures/PrivateThreadChannel.js b/lib/structures/PrivateThreadChannel.js index dc58dd5f..ec14665e 100644 --- a/lib/structures/PrivateThreadChannel.js +++ b/lib/structures/PrivateThreadChannel.js @@ -3,9 +3,9 @@ const ThreadChannel = require("./ThreadChannel"); /** -* Represents a private thread channel. See ThreadChannel for extra properties. -* @extends ThreadChannel -*/ + * Represents a private thread channel. See ThreadChannel for extra properties. + * @extends ThreadChannel + */ class PrivateThreadChannel extends ThreadChannel { constructor(data, client, messageLimit) { super(data, client, messageLimit); diff --git a/lib/structures/PublicThreadChannel.js b/lib/structures/PublicThreadChannel.js index 4af8c17a..f063febe 100644 --- a/lib/structures/PublicThreadChannel.js +++ b/lib/structures/PublicThreadChannel.js @@ -3,9 +3,9 @@ const ThreadChannel = require("./ThreadChannel"); /** -* Represents a public thread channel. See ThreadChannel for extra properties. -* @extends ThreadChannel -*/ + * Represents a public thread channel. See ThreadChannel for extra properties. + * @extends ThreadChannel + */ class PublicThreadChannel extends ThreadChannel { constructor(data, client, messageLimit) { super(data, client, messageLimit); diff --git a/lib/structures/Role.js b/lib/structures/Role.js index fe919d47..8029f3f5 100644 --- a/lib/structures/Role.js +++ b/lib/structures/Role.js @@ -5,9 +5,9 @@ const Endpoints = require("../rest/Endpoints"); const Permission = require("./Permission"); /** -* Represents a role -* @extends Base -*/ + * Represents a role + * @extends Base + */ class Role extends Base { /** * The ID of the role @@ -144,36 +144,36 @@ class Role extends Base { } /** - * Delete the role - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Delete the role + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ delete(reason) { return this.guild.shard.client.deleteRole.call(this.guild.shard.client, this.guild.id, this.id, reason); } /** - * Edit the guild role - * @arg {Object} options The properties to edit - * @arg {Number} [options.color] The hex color of the role, in number form (ex: 0x3da5b3 or 4040115) - * @arg {Boolean} [options.hoist] Whether to hoist the role in the user list or not - * @arg {String} [options.icon] The role icon as a base64 data URI - * @arg {Boolean} [options.mentionable] Whether the role is mentionable or not - * @arg {String} [options.name] The name of the role - * @arg {BigInt | Number} [options.permissions] The role permissions number - * @arg {String?} [options.unicodeEmoji] The role's unicode emoji - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Edit the guild role + * @param {Object} options The properties to edit + * @param {Number} [options.color] The hex color of the role, in number form (ex: 0x3da5b3 or 4040115) + * @param {Boolean} [options.hoist] Whether to hoist the role in the user list or not + * @param {String} [options.icon] The role icon as a base64 data URI + * @param {Boolean} [options.mentionable] Whether the role is mentionable or not + * @param {String} [options.name] The name of the role + * @param {BigInt | Number} [options.permissions] The role permissions number + * @param {String?} [options.unicodeEmoji] The role's unicode emoji + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ edit(options, reason) { return this.guild.shard.client.editRole.call(this.guild.shard.client, this.guild.id, this.id, options, reason); } /** - * Edit the role's position. Note that role position numbers are highest on top and lowest at the bottom. - * @arg {Number} position The new position of the role - * @returns {Promise} - */ + * Edit the role's position. Note that role position numbers are highest on top and lowest at the bottom. + * @param {Number} position The new position of the role + * @returns {Promise} + */ editPosition(position) { return this.guild.shard.client.editRolePosition.call(this.guild.shard.client, this.guild.id, this.id, position); } diff --git a/lib/structures/StageChannel.js b/lib/structures/StageChannel.js index e403c8d6..a4d93482 100644 --- a/lib/structures/StageChannel.js +++ b/lib/structures/StageChannel.js @@ -3,9 +3,9 @@ const TextVoiceChannel = require("./TextVoiceChannel"); /** -* Represents a guild stage channel. -* @extends TextVoiceChannel -*/ + * Represents a guild stage channel. + * @extends TextVoiceChannel + */ class StageChannel extends TextVoiceChannel { #client; constructor(data, client, messageLimit) { @@ -21,41 +21,41 @@ class StageChannel extends TextVoiceChannel { } /** - * Create a stage instance - * @arg {Object} options The stage instance options - * @arg {String} [options.guildScheduledEventID] The ID of the guild scheduled event associated with the stage instance - * @arg {Number} [options.privacyLevel] The privacy level of the stage instance. 1 is public (deprecated), 2 is guild only - * @arg {Boolean} [options.sendStartNotification] Whether to notify @everyone that a stage instance has started or not - * @arg {String} options.topic The stage instance topic - * @returns {Promise} - */ + * Create a stage instance + * @param {Object} options The stage instance options + * @param {String} [options.guildScheduledEventID] The ID of the guild scheduled event associated with the stage instance + * @param {Number} [options.privacyLevel] The privacy level of the stage instance. 1 is public (deprecated), 2 is guild only + * @param {Boolean} [options.sendStartNotification] Whether to notify @everyone that a stage instance has started or not + * @param {String} options.topic The stage instance topic + * @returns {Promise} + */ createInstance(options) { return this.#client.createStageInstance.call(this.#client, this.id, options); } /** - * Delete the stage instance for this channel - * @returns {Promise} - */ + * Delete the stage instance for this channel + * @returns {Promise} + */ deleteInstance() { return this.#client.deleteStageInstance.call(this.#client, this.id); } /** - * Update the stage instance for this channel - * @arg {Object} options The properties to edit - * @arg {Number} [options.privacyLevel] The privacy level of the stage instance. 1 is public, 2 is guild only - * @arg {String} [options.topic] The stage instance topic - * @returns {Promise} - */ + * Update the stage instance for this channel + * @param {Object} options The properties to edit + * @param {Number} [options.privacyLevel] The privacy level of the stage instance. 1 is public, 2 is guild only + * @param {String} [options.topic] The stage instance topic + * @returns {Promise} + */ editInstance(options) { return this.#client.editStageInstance.call(this.#client, this.id, options); } /** - * Get the stage instance for this channel - * @returns {Promise} - */ + * Get the stage instance for this channel + * @returns {Promise} + */ getInstance() { return this.#client.getStageInstance.call(this.#client, this.id); } diff --git a/lib/structures/StageInstance.js b/lib/structures/StageInstance.js index 9c05a2e3..4fff8f5c 100644 --- a/lib/structures/StageInstance.js +++ b/lib/structures/StageInstance.js @@ -3,8 +3,8 @@ const Base = require("./Base"); /** -* Represents a stage instance -*/ + * Represents a stage instance + */ class StageInstance extends Base { /** * The ID of the stage instance @@ -58,20 +58,20 @@ class StageInstance extends Base { } /** - * Delete this stage instance - * @returns {Promise} - */ + * Delete this stage instance + * @returns {Promise} + */ delete() { return this.#client.deleteStageInstance.call(this.#client, this.channel.id); } /** - * Update this stage instance - * @arg {Object} options The properties to edit - * @arg {Number} [options.privacyLevel] The privacy level of the stage instance. 1 is public (deprecated), 2 is guild only - * @arg {String} [options.topic] The stage instance topic - * @returns {Promise} - */ + * Update this stage instance + * @param {Object} options The properties to edit + * @param {Number} [options.privacyLevel] The privacy level of the stage instance. 1 is public (deprecated), 2 is guild only + * @param {String} [options.topic] The stage instance topic + * @returns {Promise} + */ edit(options) { return this.#client.editStageInstance.call(this.#client, this.channel.id, options); } diff --git a/lib/structures/TextChannel.js b/lib/structures/TextChannel.js index 8999ca36..6604dafd 100644 --- a/lib/structures/TextChannel.js +++ b/lib/structures/TextChannel.js @@ -6,9 +6,9 @@ const Message = require("./Message"); const PermissionOverwrite = require("./PermissionOverwrite"); /** -* Represents a guild text channel. See GuildChannel for more properties and methods. -* @extends GuildChannel -*/ + * Represents a guild text channel. See GuildChannel for more properties and methods. + * @extends GuildChannel + */ class TextChannel extends GuildChannel { #client; constructor(data, client, messageLimit) { @@ -82,302 +82,302 @@ class TextChannel extends GuildChannel { } /** - * Add a reaction to a message - * @arg {String} messageID The ID of the message - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @returns {Promise} - */ + * Add a reaction to a message + * @param {String} messageID The ID of the message + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @returns {Promise} + */ addMessageReaction(messageID, reaction) { return this.#client.addMessageReaction.call(this.#client, this.id, messageID, reaction); } /** - * Create an invite for the channel - * @arg {Object} [options] Invite generation options - * @arg {Number} [options.maxAge] How long the invite should last in seconds - * @arg {Number} [options.maxUses] How many uses the invite should last for - * @arg {Boolean} [options.temporary] Whether the invite grants temporary membership or not - * @arg {Boolean} [options.unique] Whether the invite is unique or not - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Create an invite for the channel + * @param {Object} [options] Invite generation options + * @param {Number} [options.maxAge] How long the invite should last in seconds + * @param {Number} [options.maxUses] How many uses the invite should last for + * @param {Boolean} [options.temporary] Whether the invite grants temporary membership or not + * @param {Boolean} [options.unique] Whether the invite is unique or not + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ createInvite(options, reason) { return this.#client.createChannelInvite.call(this.#client, this.id, options, reason); } /** - * Create a message in the channel - * @arg {String | Object} content A string or object. If an object is passed: - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. - * @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {Buffer} content.attachments[].file A buffer containing file data - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Boolean} [content.enforceNonce] If set and nonce is present, check the message for uniqueness in the past few minutes - * @arg {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {Number} [content.flags] Message flags. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list - * @arg {Object} [content.messageReference] The message reference, used when replying to messages - * @arg {String} [content.messageReference.channelID] The channel ID of the referenced message - * @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message - * @arg {String} [content.messageReference.guildID] The guild ID of the referenced message - * @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message - * @arg {String | Number} [content.nonce] A value that can be used to check if the message was sent - * @arg {Object} [content.poll] A poll object. See [Discord's Documentation](https://discord.com/developers/docs/resources/poll#poll-create-request-object-poll-create-request-object-structure) for object structure - * @arg {Array} [content.stickerIDs] An array of IDs corresponding to stickers to send - * @arg {Boolean} [content.tts] Set the message TTS flag - * @returns {Promise} - */ + * Create a message in the channel + * @param {String | Object} content A string or object. If an object is passed: + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. + * @param {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. + * @param {Array} [content.attachments] The files to attach to the message + * @param {Buffer} content.attachments[].file A buffer containing file data + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Boolean} [content.enforceNonce] If set and nonce is present, check the message for uniqueness in the past few minutes + * @param {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {Number} [content.flags] Message flags. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for a list + * @param {Object} [content.messageReference] The message reference, used when replying to messages + * @param {String} [content.messageReference.channelID] The channel ID of the referenced message + * @param {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message + * @param {String} [content.messageReference.guildID] The guild ID of the referenced message + * @param {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message + * @param {String | Number} [content.nonce] A value that can be used to check if the message was sent + * @param {Object} [content.poll] A poll object. See [Discord's Documentation](https://discord.com/developers/docs/resources/poll#poll-create-request-object-poll-create-request-object-structure) for object structure + * @param {Array} [content.stickerIDs] An array of IDs corresponding to stickers to send + * @param {Boolean} [content.tts] Set the message TTS flag + * @returns {Promise} + */ createMessage(content) { return this.#client.createMessage.call(this.#client, this.id, content); } /** - * Create a thread in this channel - * @arg {String} channelID The ID of the channel - * @arg {Object} options The thread options - * @arg {Number} [options.autoArchiveDuration] Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080 - * @arg {Boolean} [options.invitable] Whether non-moderators can add other non-moderators to the thread (private threads only) - * @arg {String} options.name The thread channel name - * @arg {Number} [options.type] The channel type of the thread to create. It is recommended to explicitly set this property as this will be a required property in API v10 - * @arg {Number} [options.rateLimitPerUser] The ratelimit of the channel, in seconds. 0 means no ratelimit is enabled - * @returns {Promise} - */ + * Create a thread in this channel + * @param {String} channelID The ID of the channel + * @param {Object} options The thread options + * @param {Number} [options.autoArchiveDuration] Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080 + * @param {Boolean} [options.invitable] Whether non-moderators can add other non-moderators to the thread (private threads only) + * @param {String} options.name The thread channel name + * @param {Number} [options.type] The channel type of the thread to create. It is recommended to explicitly set this property as this will be a required property in API v10 + * @param {Number} [options.rateLimitPerUser] The ratelimit of the channel, in seconds. 0 means no ratelimit is enabled + * @returns {Promise} + */ createThread(options) { return this.#client.createThread.call(this.#client, this.id, options); } /** - * Create a thread with an existing message - * @arg {String} messageID The ID of the message to create the thread from - * @arg {Object} options The thread options - * @arg {Number} [options.autoArchiveDuration] Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080 - * @arg {String} options.name The thread channel name - * @arg {Number} [options.rateLimitPerUser] The ratelimit of the channel, in seconds. 0 means no ratelimit is enabled - * @returns {Promise} - */ + * Create a thread with an existing message + * @param {String} messageID The ID of the message to create the thread from + * @param {Object} options The thread options + * @param {Number} [options.autoArchiveDuration] Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080 + * @param {String} options.name The thread channel name + * @param {Number} [options.rateLimitPerUser] The ratelimit of the channel, in seconds. 0 means no ratelimit is enabled + * @returns {Promise} + */ createThreadWithMessage(messageID, options) { return this.#client.createThreadWithMessage.call(this.#client, this.id, messageID, options); } /** - * Create a channel webhook - * @arg {Object} options Webhook options - * @arg {String?} [options.avatar] The default avatar as a base64 data URI. Note: base64 strings alone are not base64 data URI strings - * @arg {String} options.name The default name - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} Resolves with a webhook object - */ + * Create a channel webhook + * @param {Object} options Webhook options + * @param {String?} [options.avatar] The default avatar as a base64 data URI. Note: base64 strings alone are not base64 data URI strings + * @param {String} options.name The default name + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} Resolves with a webhook object + */ createWebhook(options, reason) { return this.#client.createChannelWebhook.call(this.#client, this.id, options, reason); } /** - * Delete a message - * @arg {String} messageID The ID of the message - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Delete a message + * @param {String} messageID The ID of the message + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ deleteMessage(messageID, reason) { return this.#client.deleteMessage.call(this.#client, this.id, messageID, reason); } /** - * Bulk delete messages (bot accounts only) - * @arg {Array} messageIDs Array of message IDs to delete - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Bulk delete messages (bot accounts only) + * @param {Array} messageIDs Array of message IDs to delete + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ deleteMessages(messageIDs, reason) { return this.#client.deleteMessages.call(this.#client, this.id, messageIDs, reason); } /** - * Edit a message - * @arg {String} messageID The ID of the message - * @arg {String | Array | Object} content A string, array of strings, or object. If an object is passed: - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) - * @arg {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {Number} [content.flags] A number representing the flags to apply to the message. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for flags reference - * @returns {Promise} - */ + * Edit a message + * @param {String} messageID The ID of the message + * @param {String | Array | Object} content A string, array of strings, or object. If an object is passed: + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here. + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow. + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow. + * @param {Array} [content.attachments] The files to attach to the message + * @param {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) + * @param {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [Discord's Documentation](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Array} [content.embeds] An array of embed objects. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {Number} [content.flags] A number representing the flags to apply to the message. See [Discord's Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for flags reference + * @returns {Promise} + */ editMessage(messageID, content) { return this.#client.editMessage.call(this.#client, this.id, messageID, content); } /** - * Get all archived threads in this channel - * @arg {String} type The type of thread channel, either "public" or "private" - * @arg {Object} [options] Additional options when requesting archived threads - * @arg {Date} [options.before] List of threads to return before the timestamp - * @arg {Number} [options.limit] Maximum number of threads to return - * @returns {Promise} An object containing an array of `threads`, an array of `members` and whether the response `hasMore` threads that could be returned in a subsequent call - */ + * Get all archived threads in this channel + * @param {String} type The type of thread channel, either "public" or "private" + * @param {Object} [options] Additional options when requesting archived threads + * @param {Date} [options.before] List of threads to return before the timestamp + * @param {Number} [options.limit] Maximum number of threads to return + * @returns {Promise} An object containing an array of `threads`, an array of `members` and whether the response `hasMore` threads that could be returned in a subsequent call + */ getArchivedThreads(type, options) { return this.#client.getArchivedThreads.call(this.#client, this.id, type, options); } /** - * Get all invites in the channel - * @returns {Promise>} - */ + * Get all invites in the channel + * @returns {Promise>} + */ getInvites() { return this.#client.getChannelInvites.call(this.#client, this.id); } /** - * Get joined private archived threads in this channel - * @arg {Object} [options] Additional options when requesting archived threads - * @arg {Date} [options.before] List of threads to return before the timestamp - * @arg {Number} [options.limit] Maximum number of threads to return - * @returns {Promise} An object containing an array of `threads`, an array of `members` and whether the response `hasMore` threads that could be returned in a subsequent call - */ + * Get joined private archived threads in this channel + * @param {Object} [options] Additional options when requesting archived threads + * @param {Date} [options.before] List of threads to return before the timestamp + * @param {Number} [options.limit] Maximum number of threads to return + * @returns {Promise} An object containing an array of `threads`, an array of `members` and whether the response `hasMore` threads that could be returned in a subsequent call + */ getJoinedPrivateArchivedThreads(options) { return this.#client.getJoinedPrivateArchivedThreads.call(this.#client, this.id, options); } /** - * Get a previous message in the channel - * @arg {String} messageID The ID of the message - * @returns {Promise} - */ + * Get a previous message in the channel + * @param {String} messageID The ID of the message + * @returns {Promise} + */ getMessage(messageID) { return this.#client.getMessage.call(this.#client, this.id, messageID); } /** - * Get a list of users who reacted with a specific reaction - * @arg {String} messageID The ID of the message - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @arg {Object} [options] Options for the request. - * @arg {Number} [options.limit=100] The maximum number of users to get - * @arg {String} [options.after] Get users after this user ID - * @arg {Number} [options.type=0] The type of reaction to get - * @returns {Promise>} - */ + * Get a list of users who reacted with a specific reaction + * @param {String} messageID The ID of the message + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @param {Object} [options] Options for the request. + * @param {Number} [options.limit=100] The maximum number of users to get + * @param {String} [options.after] Get users after this user ID + * @param {Number} [options.type=0] The type of reaction to get + * @returns {Promise>} + */ getMessageReaction(messageID, reaction, options) { return this.#client.getMessageReaction.call(this.#client, this.id, messageID, reaction, options); } /** - * Get previous messages in the channel - * @arg {Object} [options] Options for the request. - * @arg {String} [options.after] Get messages after this message ID - * @arg {String} [options.around] Get messages around this message ID (does not work with limit > 100) - * @arg {String} [options.before] Get messages before this message ID - * @arg {Number} [options.limit=50] The max number of messages to get - * @returns {Promise>} - */ + * Get previous messages in the channel + * @param {Object} [options] Options for the request. + * @param {String} [options.after] Get messages after this message ID + * @param {String} [options.around] Get messages around this message ID (does not work with limit > 100) + * @param {String} [options.before] Get messages before this message ID + * @param {Number} [options.limit=50] The max number of messages to get + * @returns {Promise>} + */ getMessages(options) { return this.#client.getMessages.call(this.#client, this.id, options); } /** - * Get all the pins in the channel - * @returns {Promise>} - */ + * Get all the pins in the channel + * @returns {Promise>} + */ getPins() { return this.#client.getPins.call(this.#client, this.id); } /** - * Get all the webhooks in the channel - * @returns {Promise>} Resolves with an array of webhook objects - */ + * Get all the webhooks in the channel + * @returns {Promise>} Resolves with an array of webhook objects + */ getWebhooks() { return this.#client.getChannelWebhooks.call(this.#client, this.id); } /** - * Pin a message - * @arg {String} messageID The ID of the message - * @returns {Promise} - */ + * Pin a message + * @param {String} messageID The ID of the message + * @returns {Promise} + */ pinMessage(messageID) { return this.#client.pinMessage.call(this.#client, this.id, messageID); } /** - * Purge previous messages in the channel with an optional filter (bot accounts only) - * @arg {Object} options Options for the request - * @arg {String} [options.after] Get messages after this message ID - * @arg {String} [options.before] Get messages before this message ID - * @arg {Function} [options.filter] Optional filter function that returns a boolean when passed a Message object - * @arg {Number} options.limit The max number of messages to search through, -1 for no limit - * @arg {String} [options.reason] The reason to be displayed in audit logs - * @returns {Promise} Resolves with the number of messages deleted - */ + * Purge previous messages in the channel with an optional filter (bot accounts only) + * @param {Object} options Options for the request + * @param {String} [options.after] Get messages after this message ID + * @param {String} [options.before] Get messages before this message ID + * @param {Function} [options.filter] Optional filter function that returns a boolean when passed a Message object + * @param {Number} options.limit The max number of messages to search through, -1 for no limit + * @param {String} [options.reason] The reason to be displayed in audit logs + * @returns {Promise} Resolves with the number of messages deleted + */ purge(limit, options) { return this.#client.purgeChannel.call(this.#client, this.id, limit, options); } /** - * Remove a reaction from a message - * @arg {String} messageID The ID of the message - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @arg {String} [userID="@me"] The ID of the user to remove the reaction for - * @returns {Promise} - */ + * Remove a reaction from a message + * @param {String} messageID The ID of the message + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @param {String} [userID="@me"] The ID of the user to remove the reaction for + * @returns {Promise} + */ removeMessageReaction(messageID, reaction, userID) { return this.#client.removeMessageReaction.call(this.#client, this.id, messageID, reaction, userID); } /** - * Remove all reactions from a message for a single emoji - * @arg {String} messageID The ID of the message - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @returns {Promise} - */ + * Remove all reactions from a message for a single emoji + * @param {String} messageID The ID of the message + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @returns {Promise} + */ removeMessageReactionEmoji(messageID, reaction) { return this.#client.removeMessageReactionEmoji.call(this.#client, this.id, messageID, reaction); } /** - * Remove all reactions from a message - * @arg {String} messageID The ID of the message - * @returns {Promise} - */ + * Remove all reactions from a message + * @param {String} messageID The ID of the message + * @returns {Promise} + */ removeMessageReactions(messageID) { return this.#client.removeMessageReactions.call(this.#client, this.id, messageID); } /** - * Send typing status in the channel - * @returns {Promise} - */ + * Send typing status in the channel + * @returns {Promise} + */ sendTyping() { return this.#client.sendChannelTyping.call(this.#client, this.id); } /** - * Unpin a message - * @arg {String} messageID The ID of the message - * @returns {Promise} - */ + * Unpin a message + * @param {String} messageID The ID of the message + * @returns {Promise} + */ unpinMessage(messageID) { return this.#client.unpinMessage.call(this.#client, this.id, messageID); } /** - * Un-send a message. You're welcome Programmix - * @arg {String} messageID The ID of the message - * @returns {Promise} - */ + * Un-send a message. You're welcome Programmix + * @param {String} messageID The ID of the message + * @returns {Promise} + */ unsendMessage(messageID) { return this.#client.deleteMessage.call(this.#client, this.id, messageID); } diff --git a/lib/structures/TextVoiceChannel.js b/lib/structures/TextVoiceChannel.js index cefcb67f..6e94a56d 100644 --- a/lib/structures/TextVoiceChannel.js +++ b/lib/structures/TextVoiceChannel.js @@ -5,9 +5,9 @@ const Collection = require("../util/Collection"); const Message = require("./Message"); /** -* Represents a Text-in-Voice channel. See VoiceChannel for more properties and methods. -* @extends VoiceChannel -*/ + * Represents a Text-in-Voice channel. See VoiceChannel for more properties and methods. + * @extends VoiceChannel + */ class TextVoiceChannel extends VoiceChannel { #client; constructor(data, client, messageLimit) { @@ -57,196 +57,196 @@ class TextVoiceChannel extends VoiceChannel { } /** - * Add a reaction to a message - * @arg {String} messageID The ID of the message - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @returns {Promise} - */ + * Add a reaction to a message + * @param {String} messageID The ID of the message + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @returns {Promise} + */ addMessageReaction(messageID, reaction) { return this.#client.addMessageReaction.call(this.#client, this.id, messageID, reaction); } /** - * Create an invite for the channel - * @arg {Object} [options] Invite generation options - * @arg {Number} [options.maxAge] How long the invite should last in seconds - * @arg {Number} [options.maxUses] How many uses the invite should last for - * @arg {Boolean} [options.temporary] Whether the invite grants temporary membership or not - * @arg {Boolean} [options.unique] Whether the invite is unique or not - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Create an invite for the channel + * @param {Object} [options] Invite generation options + * @param {Number} [options.maxAge] How long the invite should last in seconds + * @param {Number} [options.maxUses] How many uses the invite should last for + * @param {Boolean} [options.temporary] Whether the invite grants temporary membership or not + * @param {Boolean} [options.unique] Whether the invite is unique or not + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ createInvite(options, reason) { return this.#client.createChannelInvite.call(this.#client, this.id, options, reason); } /** - * Create a message in the channel - * @arg {String | Object} content A string or object. If an object is passed: - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow - * @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {Buffer} content.attachments[].file A buffer containing file data - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} content.content A content string - * @arg {Boolean} [content.enforceNonce] If set and nonce is present, check the message for uniqueness in the past few minutes - * @arg {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {Object} [content.messageReference] The message reference, used when replying to messages - * @arg {String} [content.messageReference.channelID] The channel ID of the referenced message - * @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message - * @arg {String} [content.messageReference.guildID] The guild ID of the referenced message - * @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message - * @arg {String | Number} [content.nonce] A unique value that can be used to check if the message was sent - * @arg {Object} [content.poll] A poll object. See [Discord's Documentation](https://discord.com/developers/docs/resources/poll#poll-create-request-object-poll-create-request-object-structure) for object structure - * @arg {Array} [content.stickerIDs] An array of IDs corresponding to the stickers to send - * @arg {Boolean} [content.tts] Set the message TTS flag - * @returns {Promise} - */ + * Create a message in the channel + * @param {String | Object} content A string or object. If an object is passed: + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow + * @param {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to + * @param {Array} [content.attachments] The files to attach to the message + * @param {Buffer} content.attachments[].file A buffer containing file data + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} content.content A content string + * @param {Boolean} [content.enforceNonce] If set and nonce is present, check the message for uniqueness in the past few minutes + * @param {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {Object} [content.messageReference] The message reference, used when replying to messages + * @param {String} [content.messageReference.channelID] The channel ID of the referenced message + * @param {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message + * @param {String} [content.messageReference.guildID] The guild ID of the referenced message + * @param {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message + * @param {String | Number} [content.nonce] A unique value that can be used to check if the message was sent + * @param {Object} [content.poll] A poll object. See [Discord's Documentation](https://discord.com/developers/docs/resources/poll#poll-create-request-object-poll-create-request-object-structure) for object structure + * @param {Array} [content.stickerIDs] An array of IDs corresponding to the stickers to send + * @param {Boolean} [content.tts] Set the message TTS flag + * @returns {Promise} + */ createMessage(content) { return this.#client.createMessage.call(this.#client, this.id, content); } /** - * Delete a message - * @arg {String} messageID The ID of the message - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Delete a message + * @param {String} messageID The ID of the message + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ deleteMessage(messageID, reason) { return this.#client.deleteMessage.call(this.#client, this.id, messageID, reason); } /** - * Bulk delete messages (bot accounts only) - * @arg {Array} messageIDs Array of message IDs to delete - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Bulk delete messages (bot accounts only) + * @param {Array} messageIDs Array of message IDs to delete + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ deleteMessages(messageIDs, reason) { return this.#client.deleteMessages.call(this.#client, this.id, messageIDs, reason); } /** - * Edit a message - * @arg {String} messageID The ID of the message - * @arg {String | Array | Object} content A string, array of strings, or object. If an object is passed: - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) - * @arg {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} content.content A content string - * @arg {Boolean} [content.disableEveryone] Whether to filter @everyone/@here or not (overrides default) - * @arg {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {Number} [content.flags] A number representing the flags to apply to the message. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for flags reference - * @returns {Promise} - */ + * Edit a message + * @param {String} messageID The ID of the message + * @param {String | Array | Object} content A string, array of strings, or object. If an object is passed: + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow + * @param {Array} [content.attachments] The files to attach to the message + * @param {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) + * @param {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} content.content A content string + * @param {Boolean} [content.disableEveryone] Whether to filter @everyone/@here or not (overrides default) + * @param {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {Number} [content.flags] A number representing the flags to apply to the message. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for flags reference + * @returns {Promise} + */ editMessage(messageID, content) { return this.#client.editMessage.call(this.#client, this.id, messageID, content); } /** - * Get all invites in the channel - * @returns {Promise>} - */ + * Get all invites in the channel + * @returns {Promise>} + */ getInvites() { return this.#client.getChannelInvites.call(this.#client, this.id); } /** - * Get a previous message in the channel - * @arg {String} messageID The ID of the message - * @returns {Promise} - */ + * Get a previous message in the channel + * @param {String} messageID The ID of the message + * @returns {Promise} + */ getMessage(messageID) { return this.#client.getMessage.call(this.#client, this.id, messageID); } /** - * Get a list of users who reacted with a specific reaction - * @arg {String} messageID The ID of the message - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @arg {Object} [options] Options for the request. - * @arg {Number} [options.limit=100] The maximum number of users to get - * @arg {String} [options.after] Get users after this user ID - * @arg {Number} [options.type=0] The type of reaction to get - * @returns {Promise>} - */ + * Get a list of users who reacted with a specific reaction + * @param {String} messageID The ID of the message + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @param {Object} [options] Options for the request. + * @param {Number} [options.limit=100] The maximum number of users to get + * @param {String} [options.after] Get users after this user ID + * @param {Number} [options.type=0] The type of reaction to get + * @returns {Promise>} + */ getMessageReaction(messageID, reaction, options) { return this.#client.getMessageReaction.call(this.#client, this.id, messageID, reaction, options); } /** - * Get previous messages in the channel - * @arg {Object} [options] Options for the request. - * @arg {String} [options.after] Get messages after this message ID - * @arg {String} [options.around] Get messages around this message ID (does not work with limit > 100) - * @arg {String} [options.before] Get messages before this message ID - * @arg {Number} [options.limit=50] The max number of messages to get - * @returns {Promise>} - */ + * Get previous messages in the channel + * @param {Object} [options] Options for the request. + * @param {String} [options.after] Get messages after this message ID + * @param {String} [options.around] Get messages around this message ID (does not work with limit > 100) + * @param {String} [options.before] Get messages before this message ID + * @param {Number} [options.limit=50] The max number of messages to get + * @returns {Promise>} + */ getMessages(options) { return this.#client.getMessages.call(this.#client, this.id, options); } /** - * Purge previous messages in the channel with an optional filter (bot accounts only) - * @arg {Object} options Options for the request. - * @arg {String} [options.after] Get messages after this message ID - * @arg {String} [options.before] Get messages before this message ID - * @arg {Function} [options.filter] Optional filter function that returns a boolean when passed a Message object - * @arg {Number} options.limit The max number of messages to search through, -1 for no limit - * @arg {String} [options.reason] The reason to be displayed in audit logs - * @returns {Promise} Resolves with the number of messages deleted - */ + * Purge previous messages in the channel with an optional filter (bot accounts only) + * @param {Object} options Options for the request. + * @param {String} [options.after] Get messages after this message ID + * @param {String} [options.before] Get messages before this message ID + * @param {Function} [options.filter] Optional filter function that returns a boolean when passed a Message object + * @param {Number} options.limit The max number of messages to search through, -1 for no limit + * @param {String} [options.reason] The reason to be displayed in audit logs + * @returns {Promise} Resolves with the number of messages deleted + */ purge(limit, options) { return this.#client.purgeChannel.call(this.#client, this.id, limit, options); } /** - * Remove a reaction from a message - * @arg {String} messageID The ID of the message - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @arg {String} [userID="@me"] The ID of the user to remove the reaction for - * @returns {Promise} - */ + * Remove a reaction from a message + * @param {String} messageID The ID of the message + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @param {String} [userID="@me"] The ID of the user to remove the reaction for + * @returns {Promise} + */ removeMessageReaction(messageID, reaction, userID) { return this.#client.removeMessageReaction.call(this.#client, this.id, messageID, reaction, userID); } /** - * Remove all reactions from a message for a single emoji - * @arg {String} messageID The ID of the message - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @returns {Promise} - */ + * Remove all reactions from a message for a single emoji + * @param {String} messageID The ID of the message + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @returns {Promise} + */ removeMessageReactionEmoji(messageID, reaction) { return this.#client.removeMessageReactionEmoji.call(this.#client, this.id, messageID, reaction); } /** - * Remove all reactions from a message - * @arg {String} messageID The ID of the message - * @returns {Promise} - */ + * Remove all reactions from a message + * @param {String} messageID The ID of the message + * @returns {Promise} + */ removeMessageReactions(messageID) { return this.#client.removeMessageReactions.call(this.#client, this.id, messageID); } /** - * Send typing status in the channel - * @returns {Promise} - */ + * Send typing status in the channel + * @returns {Promise} + */ sendTyping() { return this.#client.sendChannelTyping.call(this.#client, this.id); } diff --git a/lib/structures/ThreadChannel.js b/lib/structures/ThreadChannel.js index 0a29e918..5cf11fd6 100644 --- a/lib/structures/ThreadChannel.js +++ b/lib/structures/ThreadChannel.js @@ -6,9 +6,9 @@ const Message = require("./Message"); const ThreadMember = require("./ThreadMember"); /** -* Represents a thread channel. You also probably want to look at NewsThreadChannel, PublicThreadChannel, and PrivateThreadChannel. -* @extends GuildChannel -*/ + * Represents a thread channel. You also probably want to look at NewsThreadChannel, PublicThreadChannel, and PrivateThreadChannel. + * @extends GuildChannel + */ class ThreadChannel extends GuildChannel { #client; constructor(data, client, messageLimit) { @@ -89,94 +89,94 @@ class ThreadChannel extends GuildChannel { } /** - * Add a reaction to a message - * @arg {String} messageID The ID of the message - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @returns {Promise} - */ + * Add a reaction to a message + * @param {String} messageID The ID of the message + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @returns {Promise} + */ addMessageReaction(messageID, reaction) { return this.#client.addMessageReaction.call(this.#client, this.id, messageID, reaction); } /** - * Create a message in the channel - * @arg {String | Object} content A string or object. If an object is passed: - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow - * @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {Buffer} content.attachments[].file A buffer containing file data - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Boolean} [content.enforceNonce] If set and nonce is present, check the message for uniqueness in the past few minutes - * @arg {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {Object} [content.messageReference] The message reference, used when replying to messages - * @arg {String} [content.messageReference.channelID] The channel ID of the referenced message - * @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message - * @arg {String} [content.messageReference.guildID] The guild ID of the referenced message - * @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message - * @arg {String | Number} [content.nonce] A value that can be used to check if the message was sent - * @arg {Object} [content.poll] A poll object. See [Discord's Documentation](https://discord.com/developers/docs/resources/poll#poll-create-request-object-poll-create-request-object-structure) for object structure - * @arg {Array} [content.stickerIDs] An array of IDs corresponding to stickers to send - * @arg {Boolean} [content.tts] Set the message TTS flag - * @returns {Promise} - */ + * Create a message in the channel + * @param {String | Object} content A string or object. If an object is passed: + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow + * @param {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to. + * @param {Array} [content.attachments] The files to attach to the message + * @param {Buffer} content.attachments[].file A buffer containing file data + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Boolean} [content.enforceNonce] If set and nonce is present, check the message for uniqueness in the past few minutes + * @param {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {Object} [content.messageReference] The message reference, used when replying to messages + * @param {String} [content.messageReference.channelID] The channel ID of the referenced message + * @param {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message + * @param {String} [content.messageReference.guildID] The guild ID of the referenced message + * @param {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message + * @param {String | Number} [content.nonce] A value that can be used to check if the message was sent + * @param {Object} [content.poll] A poll object. See [Discord's Documentation](https://discord.com/developers/docs/resources/poll#poll-create-request-object-poll-create-request-object-structure) for object structure + * @param {Array} [content.stickerIDs] An array of IDs corresponding to stickers to send + * @param {Boolean} [content.tts] Set the message TTS flag + * @returns {Promise} + */ createMessage(content) { return this.#client.createMessage.call(this.#client, this.id, content); } /** - * Delete a message - * @arg {String} messageID The ID of the message - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Delete a message + * @param {String} messageID The ID of the message + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ deleteMessage(messageID, reason) { return this.#client.deleteMessage.call(this.#client, this.id, messageID, reason); } /** - * Bulk delete messages (bot accounts only) - * @arg {Array} messageIDs Array of message IDs to delete - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Bulk delete messages (bot accounts only) + * @param {Array} messageIDs Array of message IDs to delete + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ deleteMessages(messageIDs, reason) { return this.#client.deleteMessages.call(this.#client, this.id, messageIDs, reason); } /** - * Edit a message - * @arg {String} messageID The ID of the message - * @arg {String | Array | Object} content A string, array of strings, or object. If an object is passed: - * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default) - * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here - * @arg {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow - * @arg {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow - * @arg {Array} [content.attachments] The files to attach to the message - * @arg {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) - * @arg {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) - * @arg {String} content.attachments[].filename What to name the file - * @arg {String} [content.attachments[].description] A description for the attachment - * @arg {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure - * @arg {String} [content.content] A content string - * @arg {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure - * @arg {Number} [content.flags] A number representing the flags to apply to the message. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for flags reference - * @returns {Promise} - */ + * Edit a message + * @param {String} messageID The ID of the message + * @param {String | Array | Object} content A string, array of strings, or object. If an object is passed: + * @param {Object} [content.allowedMentions] A list of mentions to allow (overrides default) + * @param {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here + * @param {Boolean | Array} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow + * @param {Boolean | Array} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow + * @param {Array} [content.attachments] The files to attach to the message + * @param {String} content.attachments[].id The ID of an attachment (set only when you want to update an attachment) + * @param {Buffer} content.attachments[].file A buffer containing file data (set only when uploading new files) + * @param {String} content.attachments[].filename What to name the file + * @param {String} [content.attachments[].description] A description for the attachment + * @param {Array} [content.components] An array of components. See [the official Discord API documentation entry](https://discord.com/developers/docs/interactions/message-components#what-is-a-component) for object structure + * @param {String} [content.content] A content string + * @param {Array} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure + * @param {Number} [content.flags] A number representing the flags to apply to the message. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for flags reference + * @returns {Promise} + */ editMessage(messageID, content) { return this.#client.editMessage.call(this.#client, this.id, messageID, content); } /** * Gets a thread member object for a specified user - * @arg {String} memberID The ID of the member - * @arg {Object} [options] Options for the request - * @arg {Boolean} [options.withMember] Whether to include a Member object for each thread member + * @param {String} memberID The ID of the member + * @param {Object} [options] Options for the request + * @param {Boolean} [options.withMember] Whether to include a Member object for each thread member * @returns {Promise} */ getMember(memberID, options) { @@ -184,154 +184,154 @@ class ThreadChannel extends GuildChannel { } /** - * Get a list of members that are part of this thread channel - * @arg {Object} [options] Options for the request - * @arg {String} [options.after] Fetch thread members after this user ID - * @arg {Number} [options.limit] The maximum amount of thread members to fetch - * @arg {Boolean} [options.withMember] Whether to include a Member object for each thread member - * @returns {Promise>} - */ + * Get a list of members that are part of this thread channel + * @param {Object} [options] Options for the request + * @param {String} [options.after] Fetch thread members after this user ID + * @param {Number} [options.limit] The maximum amount of thread members to fetch + * @param {Boolean} [options.withMember] Whether to include a Member object for each thread member + * @returns {Promise>} + */ getMembers(options) { return this.#client.getThreadMembers.call(this.#client, this.id, options); } /** - * Get a previous message in the channel - * @arg {String} messageID The ID of the message - * @returns {Promise} - */ + * Get a previous message in the channel + * @param {String} messageID The ID of the message + * @returns {Promise} + */ getMessage(messageID) { return this.#client.getMessage.call(this.#client, this.id, messageID); } /** - * Get a list of users who reacted with a specific reaction - * @arg {String} messageID The ID of the message - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @arg {Object} [options] Options for the request. - * @arg {Number} [options.limit=100] The maximum number of users to get - * @arg {String} [options.after] Get users after this user ID - * @arg {Number} [options.type=0] The type of reaction to get - * @returns {Promise>} - */ + * Get a list of users who reacted with a specific reaction + * @param {String} messageID The ID of the message + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @param {Object} [options] Options for the request. + * @param {Number} [options.limit=100] The maximum number of users to get + * @param {String} [options.after] Get users after this user ID + * @param {Number} [options.type=0] The type of reaction to get + * @returns {Promise>} + */ getMessageReaction(messageID, reaction, options) { return this.#client.getMessageReaction.call(this.#client, this.id, messageID, reaction, options); } /** - * Get previous messages in the channel - * @arg {Object} [options] Options for the request. - * @arg {String} [options.after] Get messages after this message ID - * @arg {String} [options.around] Get messages around this message ID (does not work with limit > 100) - * @arg {String} [options.before] Get messages before this message ID - * @arg {Number} [options.limit=50] The max number of messages to get - * @returns {Promise>} - */ + * Get previous messages in the channel + * @param {Object} [options] Options for the request. + * @param {String} [options.after] Get messages after this message ID + * @param {String} [options.around] Get messages around this message ID (does not work with limit > 100) + * @param {String} [options.before] Get messages before this message ID + * @param {Number} [options.limit=50] The max number of messages to get + * @returns {Promise>} + */ getMessages(options) { return this.#client.getMessages.call(this.#client, this.id, options); } /** - * Get all the pins in the channel - * @returns {Promise>} - */ + * Get all the pins in the channel + * @returns {Promise>} + */ getPins() { return this.#client.getPins.call(this.#client, this.id); } /** - * Join a thread - * @arg {String} [userID="@me"] The user ID of the user joining - * @returns {Promise} - */ + * Join a thread + * @param {String} [userID="@me"] The user ID of the user joining + * @returns {Promise} + */ join(userID) { return this.#client.joinThread.call(this.#client, this.id, userID); } /** - * Leave a thread - * @arg {String} [userID="@me"] The user ID of the user leaving - * @returns {Promise} - */ + * Leave a thread + * @param {String} [userID="@me"] The user ID of the user leaving + * @returns {Promise} + */ leave(userID) { return this.#client.leaveThread.call(this.#client, this.id, userID); } /** - * Pin a message - * @arg {String} messageID The ID of the message - * @returns {Promise} - */ + * Pin a message + * @param {String} messageID The ID of the message + * @returns {Promise} + */ pinMessage(messageID) { return this.#client.pinMessage.call(this.#client, this.id, messageID); } /** - * Purge previous messages in the channel with an optional filter (bot accounts only) - * @arg {Object} options Options for the request. If this is a number - * @arg {String} [options.after] Get messages after this message ID - * @arg {String} [options.before] Get messages before this message ID - * @arg {Function} [options.filter] Optional filter function that returns a boolean when passed a Message object - * @arg {Number} options.limit The max number of messages to search through, -1 for no limit - * @arg {String} [options.reason] The reason to be displayed in audit logs - * @returns {Promise} Resolves with the number of messages deleted - */ + * Purge previous messages in the channel with an optional filter (bot accounts only) + * @param {Object} options Options for the request. If this is a number + * @param {String} [options.after] Get messages after this message ID + * @param {String} [options.before] Get messages before this message ID + * @param {Function} [options.filter] Optional filter function that returns a boolean when passed a Message object + * @param {Number} options.limit The max number of messages to search through, -1 for no limit + * @param {String} [options.reason] The reason to be displayed in audit logs + * @returns {Promise} Resolves with the number of messages deleted + */ purge(options) { return this.#client.purgeChannel.call(this.#client, this.id, options); } /** - * Remove a reaction from a message - * @arg {String} messageID The ID of the message - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @arg {String} [userID="@me"] The ID of the user to remove the reaction for - * @returns {Promise} - */ + * Remove a reaction from a message + * @param {String} messageID The ID of the message + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @param {String} [userID="@me"] The ID of the user to remove the reaction for + * @returns {Promise} + */ removeMessageReaction(messageID, reaction, userID) { return this.#client.removeMessageReaction.call(this.#client, this.id, messageID, reaction, userID); } /** - * Remove all reactions from a message for a single emoji - * @arg {String} messageID The ID of the message - * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) - * @returns {Promise} - */ + * Remove all reactions from a message for a single emoji + * @param {String} messageID The ID of the message + * @param {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji) + * @returns {Promise} + */ removeMessageReactionEmoji(messageID, reaction) { return this.#client.removeMessageReactionEmoji.call(this.#client, this.id, messageID, reaction); } /** - * Remove all reactions from a message - * @arg {String} messageID The ID of the message - * @returns {Promise} - */ + * Remove all reactions from a message + * @param {String} messageID The ID of the message + * @returns {Promise} + */ removeMessageReactions(messageID) { return this.#client.removeMessageReactions.call(this.#client, this.id, messageID); } /** - * Send typing status in the channel - * @returns {Promise} - */ + * Send typing status in the channel + * @returns {Promise} + */ sendTyping() { return this.#client.sendChannelTyping.call(this.#client, this.id); } /** - * Unpin a message - * @arg {String} messageID The ID of the message - * @returns {Promise} - */ + * Unpin a message + * @param {String} messageID The ID of the message + * @returns {Promise} + */ unpinMessage(messageID) { return this.#client.unpinMessage.call(this.#client, this.id, messageID); } /** - * Un-send a message. You're welcome Programmix - * @arg {String} messageID The ID of the message - * @returns {Promise} - */ + * Un-send a message. You're welcome Programmix + * @param {String} messageID The ID of the message + * @returns {Promise} + */ unsendMessage(messageID) { return this.#client.deleteMessage.call(this.#client, this.id, messageID); } diff --git a/lib/structures/ThreadMember.js b/lib/structures/ThreadMember.js index a04b6ebf..bfa07921 100644 --- a/lib/structures/ThreadMember.js +++ b/lib/structures/ThreadMember.js @@ -4,9 +4,9 @@ const Base = require("./Base"); const Member = require("./Member"); /** -* Represents a thread member -* @extends Base -*/ + * Represents a thread member + * @extends Base + */ class ThreadMember extends Base { /** * The ID of the thread member @@ -58,9 +58,9 @@ class ThreadMember extends Base { } /** - * Remove the member from the thread - * @returns {Promise} - */ + * Remove the member from the thread + * @returns {Promise} + */ leave() { return this.#client.leaveThread.call(this.#client, this.threadID, this.id); } diff --git a/lib/structures/UnavailableGuild.js b/lib/structures/UnavailableGuild.js index 18281eb8..1ca88ae3 100644 --- a/lib/structures/UnavailableGuild.js +++ b/lib/structures/UnavailableGuild.js @@ -3,9 +3,9 @@ const Base = require("./Base"); /** -* Represents a guild -* @extends Base -*/ + * Represents a guild + * @extends Base + */ class UnavailableGuild extends Base { /** * The ID of the guild diff --git a/lib/structures/User.js b/lib/structures/User.js index 9a5fa01a..a2abc959 100644 --- a/lib/structures/User.js +++ b/lib/structures/User.js @@ -4,9 +4,9 @@ const Base = require("./Base"); const Endpoints = require("../rest/Endpoints"); /** -* Represents a user -* @extends Base -*/ + * Represents a user + * @extends Base + */ class User extends Base { /** * The ID of the user @@ -108,7 +108,6 @@ class User extends Base { return this.avatar ? this.#client._formatImage(Endpoints.USER_AVATAR(this.id, this.avatar)) : this.defaultAvatarURL; } - /** * The URL of the user's avatar decoration, which is usually an animated PNG * @type {String?} @@ -174,11 +173,11 @@ class User extends Base { } /** - * Get the user's avatar with the given format and size - * @arg {String} [format] The filetype of the avatar ("jpg", "jpeg", "png", "gif", or "webp") - * @arg {Number} [size] The size of the avatar (any power of two between 16 and 4096) - * @returns {String} - */ + * Get the user's avatar with the given format and size + * @param {String} [format] The filetype of the avatar ("jpg", "jpeg", "png", "gif", or "webp") + * @param {Number} [size] The size of the avatar (any power of two between 16 and 4096) + * @returns {String} + */ dynamicAvatarURL(format, size) { if(!this.avatar) { return this.defaultAvatarURL; @@ -190,11 +189,11 @@ class User extends Base { } /** - * Get the user's banner with the given format and size - * @arg {String} [format] The filetype of the banner ("jpg", "jpeg", "png", "gif", or "webp") - * @arg {Number} [size] The size of the banner (any power of two between 16 and 4096) - * @returns {String?} - */ + * Get the user's banner with the given format and size + * @param {String} [format] The filetype of the banner ("jpg", "jpeg", "png", "gif", or "webp") + * @param {Number} [size] The size of the banner (any power of two between 16 and 4096) + * @returns {String?} + */ dynamicBannerURL(format, size) { if(!this.banner) { return null; @@ -206,9 +205,9 @@ class User extends Base { } /** - * Get a DM channel with the user, or create one if it does not exist - * @returns {Promise} - */ + * Get a DM channel with the user, or create one if it does not exist + * @returns {Promise} + */ getDMChannel() { return this.#client.getDMChannel.call(this.#client, this.id); } diff --git a/lib/structures/VoiceChannel.js b/lib/structures/VoiceChannel.js index dab49ed4..7e692d01 100644 --- a/lib/structures/VoiceChannel.js +++ b/lib/structures/VoiceChannel.js @@ -6,9 +6,9 @@ const Member = require("./Member"); const PermissionOverwrite = require("./PermissionOverwrite"); /** -* Represents a guild voice channel. See GuildChannel for more properties and methods. -* @extends GuildChannel -*/ + * Represents a guild voice channel. See GuildChannel for more properties and methods. + * @extends GuildChannel + */ class VoiceChannel extends GuildChannel { #client; constructor(data, client) { @@ -65,43 +65,43 @@ class VoiceChannel extends GuildChannel { } /** - * Create an invite for the channel - * @arg {Object} [options] Invite generation options - * @arg {Number} [options.maxAge] How long the invite should last in seconds - * @arg {Number} [options.maxUses] How many uses the invite should last for - * @arg {Boolean} [options.temporary] Whether the invite grants temporary membership or not - * @arg {Boolean} [options.unique] Whether the invite is unique or not - * @arg {String} [reason] The reason to be displayed in audit logs - * @returns {Promise} - */ + * Create an invite for the channel + * @param {Object} [options] Invite generation options + * @param {Number} [options.maxAge] How long the invite should last in seconds + * @param {Number} [options.maxUses] How many uses the invite should last for + * @param {Boolean} [options.temporary] Whether the invite grants temporary membership or not + * @param {Boolean} [options.unique] Whether the invite is unique or not + * @param {String} [reason] The reason to be displayed in audit logs + * @returns {Promise} + */ createInvite(options, reason) { return this.#client.createChannelInvite.call(this.#client, this.id, options, reason); } /** - * Get all invites in the channel - * @returns {Promise>} - */ + * Get all invites in the channel + * @returns {Promise>} + */ getInvites() { return this.#client.getChannelInvites.call(this.#client, this.id); } /** - * Joins the channel. - * @arg {Object} [options] VoiceConnection constructor options - * @arg {Object} [options.opusOnly] Skip opus encoder initialization. You should not enable this unless you know what you are doing - * @arg {Object} [options.shared] Whether the VoiceConnection will be part of a SharedStream or not - * @arg {Boolean} [options.selfMute] Whether the bot joins the channel muted or not - * @arg {Boolean} [options.selfDeaf] Whether the bot joins the channel deafened or not - * @returns {Promise} Resolves with a VoiceConnection - */ + * Joins the channel. + * @param {Object} [options] VoiceConnection constructor options + * @param {Object} [options.opusOnly] Skip opus encoder initialization. You should not enable this unless you know what you are doing + * @param {Object} [options.shared] Whether the VoiceConnection will be part of a SharedStream or not + * @param {Boolean} [options.selfMute] Whether the bot joins the channel muted or not + * @param {Boolean} [options.selfDeaf] Whether the bot joins the channel deafened or not + * @returns {Promise} Resolves with a VoiceConnection + */ join(options) { return this.#client.joinVoiceChannel.call(this.#client, this.id, options); } /** - * Leaves the channel. - */ + * Leaves the channel. + */ leave() { return this.#client.leaveVoiceChannel.call(this.#client, this.id); } diff --git a/lib/structures/VoiceState.js b/lib/structures/VoiceState.js index ae5eff1c..b6777fa6 100644 --- a/lib/structures/VoiceState.js +++ b/lib/structures/VoiceState.js @@ -3,9 +3,9 @@ const Base = require("./Base"); /** -* Represents a member's voice state in a guild -* @extends Base -*/ + * Represents a member's voice state in a guild + * @extends Base + */ class VoiceState extends Base { /** * The ID of the member diff --git a/lib/util/BrowserWebSocket.js b/lib/util/BrowserWebSocket.js index 81661cc4..9692d27a 100644 --- a/lib/util/BrowserWebSocket.js +++ b/lib/util/BrowserWebSocket.js @@ -16,9 +16,9 @@ class BrowserWebSocketError extends Error { } /** -* Represents a browser's websocket usable by Dysnomia -* @extends EventEmitter -*/ + * Represents a browser's websocket usable by Dysnomia + * @extends EventEmitter + */ class BrowserWebSocket extends EventEmitter { #ws; /** diff --git a/lib/util/Bucket.js b/lib/util/Bucket.js index 4680d8df..1f6faad0 100644 --- a/lib/util/Bucket.js +++ b/lib/util/Bucket.js @@ -4,8 +4,8 @@ const util = require("node:util"); const Base = require("../structures/Base"); /** -* Handle ratelimiting something -*/ + * Handle ratelimiting something + */ class Bucket { #queue = []; /** @@ -24,14 +24,14 @@ class Bucket { */ tokens = 0; /** - * Construct a Bucket - * @arg {Number} tokenLimit The max number of tokens the bucket can consume per interval - * @arg {Number} interval How long (in ms) to wait between clearing used tokens - * @arg {Object} [options] Optional parameters - * @arg {Object} options.latencyRef A latency reference object - * @arg {Number} options.latencyRef.latency Interval between consuming tokens - * @arg {Number} options.reservedTokens How many tokens to reserve for priority operations - */ + * Construct a Bucket + * @param {Number} tokenLimit The max number of tokens the bucket can consume per interval + * @param {Number} interval How long (in ms) to wait between clearing used tokens + * @param {Object} [options] Optional parameters + * @param {Object} options.latencyRef A latency reference object + * @param {Number} options.latencyRef.latency Interval between consuming tokens + * @param {Number} options.reservedTokens How many tokens to reserve for priority operations + */ constructor(tokenLimit, interval, options = {}) { /** * The max number tokens the bucket can consume per interval @@ -85,11 +85,11 @@ class Bucket { } /** - * Queue something in the Bucket - * @arg {Function} func A callback to call when a token can be consumed - * @arg {Boolean} [priority=false] Whether or not the callback should use reserved tokens - */ - queue(func, priority=false) { + * Queue something in the Bucket + * @param {Function} func A callback to call when a token can be consumed + * @param {Boolean} [priority=false] Whether or not the callback should use reserved tokens + */ + queue(func, priority = false) { if(priority) { this.#queue.unshift({func, priority}); } else { diff --git a/lib/util/Collection.js b/lib/util/Collection.js index f77b8e96..d8d0e8f5 100644 --- a/lib/util/Collection.js +++ b/lib/util/Collection.js @@ -1,16 +1,16 @@ "use strict"; /** -* Hold a bunch of something -* @template Class -* @extends Map -*/ + * Hold a bunch of something + * @template Class + * @extends Map + */ class Collection extends Map { /** - * Construct a Collection - * @arg {Class} baseObject The base class for all items - * @arg {Number} [limit] Max number of items to hold - */ + * Construct a Collection + * @param {Class} baseObject The base class for all items + * @param {Number} [limit] Max number of items to hold + */ constructor(baseObject, limit) { super(); /** @@ -26,13 +26,13 @@ class Collection extends Map { } /** - * Update an object - * @arg {Object} obj The updated object data - * @arg {String} obj.id The ID of the object - * @arg {Class} [extra] An extra parameter the constructor may need - * @arg {Boolean} [replace] Whether to replace an existing object with the same ID - * @returns {Class} The updated object - */ + * Update an object + * @param {Object} obj The updated object data + * @param {String} obj.id The ID of the object + * @param {Class} [extra] An extra parameter the constructor may need + * @param {Boolean} [replace] Whether to replace an existing object with the same ID + * @returns {Class} The updated object + */ update(obj, extra, replace) { if(!obj.id && obj.id !== 0) { throw new Error("Missing object id"); @@ -46,13 +46,13 @@ class Collection extends Map { } /** - * Add an object - * @arg {Object} obj The object data - * @arg {String} obj.id The ID of the object - * @arg {Class} [extra] An extra parameter the constructor may need - * @arg {Boolean} [replace] Whether to replace an existing object with the same ID - * @returns {Class} The existing or newly created object - */ + * Add an object + * @param {Object} obj The object data + * @param {String} obj.id The ID of the object + * @param {Class} [extra] An extra parameter the constructor may need + * @param {Boolean} [replace] Whether to replace an existing object with the same ID + * @returns {Class} The existing or newly created object + */ add(obj, extra, replace) { if(this.limit === 0) { return (obj instanceof this.baseObject || obj.constructor.name === this.baseObject.name) ? obj : new this.baseObject(obj, extra); @@ -81,7 +81,7 @@ class Collection extends Map { /** * Returns true if all elements satisfy the condition - * @arg {Function} func A function that takes an object and returns true or false + * @param {Function} func A function that takes an object and returns true or false * @returns {Boolean} Whether or not all elements satisfied the condition */ every(func) { @@ -94,10 +94,10 @@ class Collection extends Map { } /** - * Return all the objects that make the function evaluate true - * @arg {Function} func A function that takes an object and returns true if it matches - * @returns {Array} An array containing all the objects that matched - */ + * Return all the objects that make the function evaluate true + * @param {Function} func A function that takes an object and returns true if it matches + * @returns {Array} An array containing all the objects that matched + */ filter(func) { const arr = []; for(const item of this.values()) { @@ -109,10 +109,10 @@ class Collection extends Map { } /** - * Return the first object to make the function evaluate true - * @arg {Function} func A function that takes an object and returns true if it matches - * @returns {Class?} The first matching object, or undefined if no match - */ + * Return the first object to make the function evaluate true + * @param {Function} func A function that takes an object and returns true if it matches + * @returns {Class?} The first matching object, or undefined if no match + */ find(func) { for(const item of this.values()) { if(func(item)) { @@ -123,10 +123,10 @@ class Collection extends Map { } /** - * Return an array with the results of applying the given function to each element - * @arg {Function} func A function that takes an object and returns something - * @returns {Array} An array containing the results - */ + * Return an array with the results of applying the given function to each element + * @param {Function} func A function that takes an object and returns something + * @returns {Array} An array containing the results + */ map(func) { const arr = []; for(const item of this.values()) { @@ -136,9 +136,9 @@ class Collection extends Map { } /** - * Get a random object from the Collection - * @returns {Class?} The random object, or undefined if there is no match - */ + * Get a random object from the Collection + * @returns {Class?} The random object, or undefined if there is no match + */ random() { const index = Math.floor(Math.random() * this.size); const iter = this.values(); @@ -150,8 +150,8 @@ class Collection extends Map { /** * Returns a value resulting from applying a function to every element of the collection - * @arg {Function} func A function that takes the previous value and the next item and returns a new value - * @arg {any} [initialValue] The initial value passed to the function + * @param {Function} func A function that takes the previous value and the next item and returns a new value + * @param {any} [initialValue] The initial value passed to the function * @returns {any} The final result */ reduce(func, initialValue) { @@ -165,11 +165,11 @@ class Collection extends Map { } /** - * Remove an object - * @arg {Object} obj The object - * @arg {String} obj.id The ID of the object - * @returns {Class?} The removed object, or null if nothing was removed - */ + * Remove an object + * @param {Object} obj The object + * @param {String} obj.id The ID of the object + * @returns {Class?} The removed object, or null if nothing was removed + */ remove(obj) { const item = this.get(obj.id); if(!item) { @@ -181,7 +181,7 @@ class Collection extends Map { /** * Returns true if at least one element satisfies the condition - * @arg {Function} func A function that takes an object and returns true or false + * @param {Function} func A function that takes an object and returns true or false * @returns {Boolean} Whether or not at least one element satisfied the condition */ some(func) { diff --git a/lib/util/MultipartData.js b/lib/util/MultipartData.js index e60f6016..e68218f5 100644 --- a/lib/util/MultipartData.js +++ b/lib/util/MultipartData.js @@ -41,12 +41,12 @@ class MultipartData { if(contentType) { str += `\r\nContent-Type: ${contentType}`; } else if(ArrayBuffer.isView(data)) { - str +="\r\nContent-Type: application/octet-stream"; + str += "\r\nContent-Type: application/octet-stream"; if(!(data instanceof Uint8Array)) { data = new Uint8Array(data.buffer, data.byteOffset, data.byteLength); } } else if(typeof data === "object") { - str +="\r\nContent-Type: application/json"; + str += "\r\nContent-Type: application/json"; data = Buffer.from(JSON.stringify(data)); } else { data = Buffer.from("" + data); diff --git a/lib/util/SequentialBucket.js b/lib/util/SequentialBucket.js index b75dba27..8233a99b 100644 --- a/lib/util/SequentialBucket.js +++ b/lib/util/SequentialBucket.js @@ -4,9 +4,9 @@ const util = require("node:util"); const Base = require("../structures/Base"); /** -* Ratelimit requests and release in sequence -* TODO: add latencyref -*/ + * Ratelimit requests and release in sequence + * TODO: add latencyref + */ class SequentialBucket { #queue = []; /** @@ -25,11 +25,11 @@ class SequentialBucket { */ /** - * Construct a SequentialBucket - * @arg {Number} limit The max number of tokens the bucket can consume per interval - * @arg {Object} [latencyRef] An object - * @arg {Number} latencyRef.latency Interval between consuming tokens - */ + * Construct a SequentialBucket + * @param {Number} limit The max number of tokens the bucket can consume per interval + * @param {Object} [latencyRef] An object + * @param {Number} latencyRef.latency Interval between consuming tokens + */ constructor(limit, latencyRef = {latency: 0}) { /** * How many tokens the bucket can consume in the current interval @@ -76,9 +76,9 @@ class SequentialBucket { } /** - * Queue something in the SequentialBucket - * @arg {Function} func A function to call when a token can be consumed. The function will be passed a callback argument, which must be called to allow the bucket to continue to work - */ + * Queue something in the SequentialBucket + * @param {Function} func A function to call when a token can be consumed. The function will be passed a callback argument, which must be called to allow the bucket to continue to work + */ queue(func, short) { if(short) { this.#queue.unshift(func); diff --git a/lib/util/emitDeprecation.js b/lib/util/emitDeprecation.js index 0da8c3f9..9a0924cf 100644 --- a/lib/util/emitDeprecation.js +++ b/lib/util/emitDeprecation.js @@ -7,7 +7,7 @@ const unknownCodeMessage = "You have triggered a deprecated behavior whose warni const emittedCodes = []; module.exports = function emitDeprecation(code) { - if(emittedCodes.includes(code) ) { + if(emittedCodes.includes(code)) { return; } emittedCodes.push(code); diff --git a/lib/voice/SharedStream.js b/lib/voice/SharedStream.js index c7180e0b..a07ee871 100644 --- a/lib/voice/SharedStream.js +++ b/lib/voice/SharedStream.js @@ -15,9 +15,9 @@ try { } /** -* Represents a collection of VoiceConnections sharing an input stream -* @extends EventEmitter -*/ + * Represents a collection of VoiceConnections sharing an input stream + * @extends EventEmitter + */ class SharedStream extends EventEmitter { #send; bitrate = 64_000; @@ -50,10 +50,10 @@ class SharedStream extends EventEmitter { this.piper = new Piper(VoiceConnection._converterCommand.cmd, () => createOpus(this.samplingRate, this.channels, this.bitrate)); /** - * Fired when the shared stream encounters an error - * @event SharedStream#error - * @prop {Error} e The error - */ + * Fired when the shared stream encounters an error + * @event SharedStream#error + * @prop {Error} e The error + */ this.piper.on("error", (e) => this.emit("error", e)); if(!VoiceConnection._converterCommand.libopus) { this.piper.libopus = false; @@ -71,9 +71,9 @@ class SharedStream extends EventEmitter { } /** - * Add a voice connection to the shared stream - * @arg {VoiceConnection} connection The voice connection to add - */ + * Add a voice connection to the shared stream + * @param {VoiceConnection} connection The voice connection to add + */ add(connection) { const _connection = this.voiceConnections.add(connection); if(_connection.ready) { @@ -87,18 +87,18 @@ class SharedStream extends EventEmitter { } /** - * Play an audio or video resource. If playing from a non-opus resource, FFMPEG should be compiled with --enable-libopus for best performance. If playing from HTTPS, FFMPEG must be compiled with --enable-openssl - * @arg {ReadableStream | String} resource The audio or video resource, either a ReadableStream, URL, or file path - * @arg {Object} [options] Music options - * @arg {Array} [options.encoderArgs] Additional encoder parameters to pass to ffmpeg/avconv (after -i) - * @arg {String} [options.format] The format of the resource. If null, FFmpeg will attempt to guess and play the format. Available options: "dca", "ogg", "webm", "pcm", null - * @arg {Number} [options.frameDuration=60] The resource opus frame duration (required for DCA/Ogg) - * @arg {Number} [options.frameSize=2880] The resource opus frame size - * @arg {Boolean} [options.inlineVolume=false] Whether to enable on-the-fly volume changing. Note that enabling this leads to increased CPU usage - * @arg {Array} [options.inputArgs] Additional input parameters to pass to ffmpeg/avconv (before -i) - * @arg {Number} [options.sampleRate=48000] The resource audio sampling rate - * @arg {Number} [options.voiceDataTimeout=2000] Timeout when waiting for voice data (-1 for no timeout) - */ + * Play an audio or video resource. If playing from a non-opus resource, FFMPEG should be compiled with --enable-libopus for best performance. If playing from HTTPS, FFMPEG must be compiled with --enable-openssl + * @param {ReadableStream | String} resource The audio or video resource, either a ReadableStream, URL, or file path + * @param {Object} [options] Music options + * @param {Array} [options.encoderArgs] Additional encoder parameters to pass to ffmpeg/avconv (after -i) + * @param {String} [options.format] The format of the resource. If null, FFmpeg will attempt to guess and play the format. Available options: "dca", "ogg", "webm", "pcm", null + * @param {Number} [options.frameDuration=60] The resource opus frame duration (required for DCA/Ogg) + * @param {Number} [options.frameSize=2880] The resource opus frame size + * @param {Boolean} [options.inlineVolume=false] Whether to enable on-the-fly volume changing. Note that enabling this leads to increased CPU usage + * @param {Array} [options.inputArgs] Additional input parameters to pass to ffmpeg/avconv (before -i) + * @param {Number} [options.sampleRate=48000] The resource audio sampling rate + * @param {Number} [options.voiceDataTimeout=2000] Timeout when waiting for voice data (-1 for no timeout) + */ play(source, options = {}) { options.format = options.format || null; options.voiceDataTimeout = !isNaN(options.voiceDataTimeout) ? options.voiceDataTimeout : 2000; @@ -135,18 +135,18 @@ class SharedStream extends EventEmitter { this.playing = true; /** - * Fired when the shared stream starts playing a stream - * @event SharedStream#start - */ + * Fired when the shared stream starts playing a stream + * @event SharedStream#start + */ this.emit("start"); this.#send(); } /** - * Remove a voice connection from the shared stream - * @arg {VoiceConnection} connection The voice connection to remove - */ + * Remove a voice connection from the shared stream + * @param {VoiceConnection} connection The voice connection to remove + */ remove(connection) { return this.voiceConnections.remove(connection); } @@ -162,15 +162,15 @@ class SharedStream extends EventEmitter { /** * Sets the volume of this shared stream if inline volume is enabled - * @arg {Number} volume The volume as a value from 0 (min) to 1 (max) + * @param {Number} volume The volume as a value from 0 (min) to 1 (max) */ setVolume(volume) { this.piper.setVolume(volume); } /** - * Stop the bot from sending audio - */ + * Stop the bot from sending audio + */ stopPlaying() { if(this.ended) { return; @@ -187,9 +187,9 @@ class SharedStream extends EventEmitter { this.setSpeaking(this.playing = false); /** - * Fired when the shared stream finishes playing a stream - * @event SharedStream#end - */ + * Fired when the shared stream finishes playing a stream + * @event SharedStream#end + */ this.emit("end"); } diff --git a/lib/voice/VoiceConnection.js b/lib/voice/VoiceConnection.js index 685bdce8..6920bea6 100644 --- a/lib/voice/VoiceConnection.js +++ b/lib/voice/VoiceConnection.js @@ -54,9 +54,9 @@ converterCommand.pickCommand = function pickCommand() { let emittedBrowserLikeRuntimeWarning = false; /** -* Represents a voice connection -* @extends EventEmitter -*/ + * Represents a voice connection + * @extends EventEmitter + */ class VoiceConnection extends EventEmitter { #send; bitrate = 64_000; @@ -142,10 +142,10 @@ class VoiceConnection extends EventEmitter { this.piper = new Piper(converterCommand.cmd, () => createOpus(this.samplingRate, this.channels, this.bitrate)); /** - * Fired when the voice connection encounters an error. This event should be handled by users - * @event VoiceConnection#error - * @prop {Error} err The error object - */ + * Fired when the voice connection encounters an error. This event should be handled by users + * @event VoiceConnection#error + * @prop {Error} err The error object + */ this.piper.on("error", (e) => this.emit("error", e)); if(!converterCommand.libopus) { this.piper.libopus = false; @@ -196,16 +196,16 @@ class VoiceConnection extends EventEmitter { this.endpoint.searchParams.set("v", 4); this.ws = new WebSocket(this.endpoint.href); /** - * Fired when stuff happens and gives more info - * @event VoiceConnection#debug - * @prop {String} message The debug message - */ + * Fired when stuff happens and gives more info + * @event VoiceConnection#debug + * @prop {String} message The debug message + */ this.emit("debug", "Connection: " + JSON.stringify(data)); this.ws.on("open", () => { /** - * Fired when the voice connection connects - * @event VoiceConnection#connect - */ + * Fired when the voice connection connects + * @event VoiceConnection#connect + */ this.emit("connect"); if(this.connectionTimeout) { clearTimeout(this.connectionTimeout); @@ -290,9 +290,9 @@ class VoiceConnection extends EventEmitter { // Send audio to properly establish the socket (e.g. for voice receive) this.sendAudioFrame(SILENCE_FRAME, this.frameSize); /** - * Fired when the voice connection turns ready - * @event VoiceConnection#ready - */ + * Fired when the voice connection turns ready + * @event VoiceConnection#ready + */ this.emit("ready"); this.resume(); if(this.receiveStreamOpus || this.receiveStreamPCM) { @@ -302,25 +302,25 @@ class VoiceConnection extends EventEmitter { } case VoiceOPCodes.HEARTBEAT_ACK: { /** - * Fired when the voice connection receives a pong - * @event VoiceConnection#pong - * @prop {Number} latency The current latency in milliseconds - */ + * Fired when the voice connection receives a pong + * @event VoiceConnection#pong + * @prop {Number} latency The current latency in milliseconds + */ this.emit("pong", Date.now() - packet.d); break; } case VoiceOPCodes.SPEAKING: { this.ssrcUserMap[packet.d.ssrc] = packet.d.user_id; /** - * Fired when a user begins speaking - * @event VoiceConnection#speakingStart - * @prop {String} userID The ID of the user that began speaking - */ + * Fired when a user begins speaking + * @event VoiceConnection#speakingStart + * @prop {String} userID The ID of the user that began speaking + */ /** - * Fired when a user stops speaking - * @event VoiceConnection#speakingStop - * @prop {String} userID The ID of the user that stopped speaking - */ + * Fired when a user stops speaking + * @event VoiceConnection#speakingStop + * @prop {String} userID The ID of the user that stopped speaking + */ this.emit(packet.d.speaking ? "speakingStart" : "speakingStop", packet.d.user_id); break; } @@ -344,10 +344,10 @@ class VoiceConnection extends EventEmitter { } /** - * Fired when a user disconnects from the voice server - * @event VoiceConnection#userDisconnect - * @prop {String} userID The ID of the user that disconnected - */ + * Fired when a user disconnects from the voice server + * @event VoiceConnection#userDisconnect + * @prop {String} userID The ID of the user that disconnected + */ this.emit("userDisconnect", packet.d.user_id); break; } @@ -451,10 +451,10 @@ class VoiceConnection extends EventEmitter { this.channelID = null; this.updateVoiceState(); /** - * Fired when the voice connection disconnects - * @event VoiceConnection#disconnect - * @prop {Error?} error The error, if any - */ + * Fired when the voice connection disconnects + * @event VoiceConnection#disconnect + * @prop {Error?} error The error, if any + */ this.emit("disconnect", error); } } @@ -469,8 +469,8 @@ class VoiceConnection extends EventEmitter { } /** - * Pause sending audio (if playing) - */ + * Pause sending audio (if playing) + */ pause() { this.paused = true; this.setSpeaking(0); @@ -486,19 +486,19 @@ class VoiceConnection extends EventEmitter { } /** - * Play an audio or video resource. If playing from a non-opus resource, FFMPEG should be compiled with --enable-libopus for best performance. If playing from HTTPS, FFMPEG must be compiled with --enable-openssl - * @arg {ReadableStream | String} resource The audio or video resource, either a ReadableStream, URL, or file path - * @arg {Object} [options] Music options - * @arg {Array} [options.encoderArgs] Additional encoder parameters to pass to ffmpeg/avconv (after -i) - * @arg {String} [options.format] The format of the resource. If null, FFmpeg will attempt to guess and play the format. Available options: "dca", "ogg", "webm", "pcm", null - * @arg {Number} [options.frameDuration=20] The resource opus frame duration (required for DCA/Ogg) - * @arg {Number} [options.frameSize=2880] The resource opus frame size - * @arg {Boolean} [options.inlineVolume=false] Whether to enable on-the-fly volume changing. Note that enabling this leads to increased CPU usage - * @arg {Array} [options.inputArgs] Additional input parameters to pass to ffmpeg/avconv (before -i) - * @arg {Number} [options.pcmSize=options.frameSize*2*this.channels] The PCM size if the "pcm" format is used - * @arg {Number} [options.samplingRate=48000] The resource audio sampling rate - * @arg {Number} [options.voiceDataTimeout=2000] Timeout when waiting for voice data (-1 for no timeout) - */ + * Play an audio or video resource. If playing from a non-opus resource, FFMPEG should be compiled with --enable-libopus for best performance. If playing from HTTPS, FFMPEG must be compiled with --enable-openssl + * @param {ReadableStream | String} resource The audio or video resource, either a ReadableStream, URL, or file path + * @param {Object} [options] Music options + * @param {Array} [options.encoderArgs] Additional encoder parameters to pass to ffmpeg/avconv (after -i) + * @param {String} [options.format] The format of the resource. If null, FFmpeg will attempt to guess and play the format. Available options: "dca", "ogg", "webm", "pcm", null + * @param {Number} [options.frameDuration=20] The resource opus frame duration (required for DCA/Ogg) + * @param {Number} [options.frameSize=2880] The resource opus frame size + * @param {Boolean} [options.inlineVolume=false] Whether to enable on-the-fly volume changing. Note that enabling this leads to increased CPU usage + * @param {Array} [options.inputArgs] Additional input parameters to pass to ffmpeg/avconv (before -i) + * @param {Number} [options.pcmSize=options.frameSize*2*this.channels] The PCM size if the "pcm" format is used + * @param {Number} [options.samplingRate=48000] The resource audio sampling rate + * @param {Number} [options.voiceDataTimeout=2000] Timeout when waiting for voice data (-1 for no timeout) + */ play(source, options = {}) { if(this.shared) { throw new Error("Cannot play stream on shared voice connection"); @@ -546,19 +546,19 @@ class VoiceConnection extends EventEmitter { this.playing = true; /** - * Fired when the voice connection starts playing a stream - * @event VoiceConnection#start - */ + * Fired when the voice connection starts playing a stream + * @event VoiceConnection#start + */ this.emit("start"); this.#send(); } /** - * Generate a receive stream for the voice connection. - * @arg {String} [type="pcm"] The desired voice data type, either "opus" or "pcm" - * @returns {VoiceDataStream} - */ + * Generate a receive stream for the voice connection. + * @param {String} [type="pcm"] The desired voice data type, either "opus" or "pcm" + * @returns {VoiceDataStream} + */ receive(type) { if(type === "pcm") { if(!this.receiveStreamPCM) { @@ -595,10 +595,10 @@ class VoiceConnection extends EventEmitter { } else { if(!(data = NaCl.secretbox.open(msg.subarray(12), nonce, this.secret))) { /** - * Fired to warn of something weird but non-breaking happening - * @event VoiceConnection#warn - * @prop {String} message The warning message - */ + * Fired to warn of something weird but non-breaking happening + * @event VoiceConnection#warn + * @prop {String} message The warning message + */ this.emit("warn", "Failed to decrypt received packet"); return; } @@ -615,13 +615,13 @@ class VoiceConnection extends EventEmitter { } if(this.receiveStreamOpus) { /** - * Fired when a voice data packet is received - * @event VoiceDataStream#data - * @prop {Buffer} data The voice data - * @prop {String} userID The user who sent the voice packet - * @prop {Number} timestamp The intended timestamp of the packet - * @prop {Number} sequence The intended sequence number of the packet - */ + * Fired when a voice data packet is received + * @event VoiceDataStream#data + * @prop {Buffer} data The voice data + * @prop {String} userID The user who sent the voice packet + * @prop {Number} timestamp The intended timestamp of the packet + * @prop {Number} sequence The intended sequence number of the packet + */ this.receiveStreamOpus.emit("data", data, this.ssrcUserMap[nonce.readUIntBE(8, 4)], nonce.readUIntBE(4, 4), nonce.readUIntBE(2, 2)); } if(this.receiveStreamPCM) { @@ -638,8 +638,8 @@ class VoiceConnection extends EventEmitter { } /** - * Resume sending audio (if paused) - */ + * Resume sending audio (if paused) + */ resume() { this.paused = false; if(this.current) { @@ -655,10 +655,10 @@ class VoiceConnection extends EventEmitter { } /** - * Send a packet containing an Opus audio frame - * @arg {Buffer} frame The Opus audio frame - * @arg {Number} [frameSize] The size (in samples) of the Opus audio frame - */ + * Send a packet containing an Opus audio frame + * @param {Buffer} frame The Opus audio frame + * @param {Number} [frameSize] The size (in samples) of the Opus audio frame + */ sendAudioFrame(frame, frameSize = this.frameSize) { this.timestamp = (this.timestamp + frameSize) >>> 0; this.sequence = (this.sequence + 1) & 0xFFFF; @@ -667,9 +667,9 @@ class VoiceConnection extends EventEmitter { } /** - * Send a packet through the connection's UDP socket. The packet is dropped if the socket isn't established - * @arg {Buffer} packet The packet data - */ + * Send a packet through the connection's UDP socket. The packet is dropped if the socket isn't established + * @param {Buffer} packet The packet data + */ sendUDPPacket(packet) { if(this.udpSocket) { try { @@ -698,16 +698,16 @@ class VoiceConnection extends EventEmitter { } /** - * Modify the output volume of the current stream (if inlineVolume is enabled for the current stream) - * @arg {Number} [volume=1.0] The desired volume. 0.0 is 0%, 1.0 is 100%, 2.0 is 200%, etc. It is not recommended to go above 2.0 - */ + * Modify the output volume of the current stream (if inlineVolume is enabled for the current stream) + * @param {Number} [volume=1.0] The desired volume. 0.0 is 0%, 1.0 is 100%, 2.0 is 200%, etc. It is not recommended to go above 2.0 + */ setVolume(volume) { this.piper.setVolume(volume); } /** - * Stop the bot from sending audio - */ + * Stop the bot from sending audio + */ stopPlaying() { if(this.ended) { return; @@ -732,16 +732,16 @@ class VoiceConnection extends EventEmitter { this.setSpeaking(0); /** - * Fired when the voice connection finishes playing a stream - * @event VoiceConnection#end - */ + * Fired when the voice connection finishes playing a stream + * @event VoiceConnection#end + */ this.emit("end"); } /** - * Switch the voice channel the bot is in. The channel to switch to must be in the same guild as the current voice channel - * @arg {String} channelID The ID of the voice channel - */ + * Switch the voice channel the bot is in. The channel to switch to must be in the same guild as the current voice channel + * @param {String} channelID The ID of the voice channel + */ switchChannel(channelID, reactive) { if(this.channelID === channelID) { return; @@ -758,10 +758,10 @@ class VoiceConnection extends EventEmitter { } /** - * Update the bot's voice state - * @arg {Boolean} selfMute Whether the bot muted itself or not (audio receiving is unaffected) - * @arg {Boolean} selfDeaf Whether the bot deafened itself or not (audio sending is unaffected) - */ + * Update the bot's voice state + * @param {Boolean} selfMute Whether the bot muted itself or not (audio receiving is unaffected) + * @param {Boolean} selfDeaf Whether the bot deafened itself or not (audio sending is unaffected) + */ updateVoiceState(selfMute, selfDeaf) { this.shard.sendWS?.(GatewayOPCodes.VOICE_STATE_UPDATE, { guild_id: this.id, @@ -843,7 +843,6 @@ class VoiceConnection extends EventEmitter { } } - [util.inspect.custom]() { return Base.prototype[util.inspect.custom].call(this); } diff --git a/lib/voice/VoiceDataStream.js b/lib/voice/VoiceDataStream.js index cdf7968f..7b120700 100644 --- a/lib/voice/VoiceDataStream.js +++ b/lib/voice/VoiceDataStream.js @@ -8,9 +8,9 @@ try { } /** -* Represents a voice data stream -* @extends EventEmitter -*/ + * Represents a voice data stream + * @extends EventEmitter + */ class VoiceDataStream extends EventEmitter { constructor(type) { super(); diff --git a/lib/voice/streams/DCAOpusTransformer.js b/lib/voice/streams/DCAOpusTransformer.js index 29ec084a..8a6fc6c0 100644 --- a/lib/voice/streams/DCAOpusTransformer.js +++ b/lib/voice/streams/DCAOpusTransformer.js @@ -22,7 +22,7 @@ class DCAOpusTransformer extends BaseTransformer { } _transform(chunk, enc, cb) { - if(this.#remainder) { + if(this.#remainder) { chunk = Buffer.concat([this.#remainder, chunk]); this.#remainder = null; } diff --git a/lib/voice/streams/FFmpegDuplex.js b/lib/voice/streams/FFmpegDuplex.js index 42d6f5d6..a853be20 100644 --- a/lib/voice/streams/FFmpegDuplex.js +++ b/lib/voice/streams/FFmpegDuplex.js @@ -91,16 +91,16 @@ class FFmpegDuplex extends DuplexStream { }; const cleanup = () => { - this.#process = - this.#stderr = - this.#stdout = - this.#stdin = - stderr = - ex = - killed = null; - - this.kill = - this.destroy = this.noop; + this.#process + = this.#stderr + = this.#stdout + = this.#stdin + = stderr + = ex + = killed = null; + + this.kill + = this.destroy = this.noop; }; const onExit = (code, signal) => { diff --git a/lib/voice/streams/OggOpusTransformer.js b/lib/voice/streams/OggOpusTransformer.js index e4c7eb0f..b8626456 100644 --- a/lib/voice/streams/OggOpusTransformer.js +++ b/lib/voice/streams/OggOpusTransformer.js @@ -76,7 +76,7 @@ class OggOpusTransformer extends BaseTransformer { } _transform(chunk, enc, cb) { - if(this.#remainder) { + if(this.#remainder) { chunk = Buffer.concat([this.#remainder, chunk]); this.#remainder = null; } diff --git a/lib/voice/streams/VolumeTransformer.js b/lib/voice/streams/VolumeTransformer.js index 7245987a..8bfbd0aa 100644 --- a/lib/voice/streams/VolumeTransformer.js +++ b/lib/voice/streams/VolumeTransformer.js @@ -19,7 +19,7 @@ class VolumeTransformer extends BaseTransformer { } _transform(chunk, enc, cb) { - if(this.#remainder) { + if(this.#remainder) { chunk = Buffer.concat([this.#remainder, chunk]); this.#remainder = null; } diff --git a/lib/voice/streams/WebmOpusTransformer.js b/lib/voice/streams/WebmOpusTransformer.js index a5812f26..225465db 100644 --- a/lib/voice/streams/WebmOpusTransformer.js +++ b/lib/voice/streams/WebmOpusTransformer.js @@ -173,7 +173,7 @@ class WebmOpusTransformer extends BaseTransformer { } _transform(chunk, enc, cb) { - if(this.#remainder) { + if(this.#remainder) { chunk = Buffer.concat([this.#remainder, chunk]); this.#remainder = null; } @@ -200,11 +200,11 @@ class WebmOpusTransformer extends BaseTransformer { module.exports = WebmOpusTransformer; const schema = { - ae: { + "ae": { name: "TrackEntry", type: "m" }, - d7: { + "d7": { name: "TrackNumber", type: "u" }, @@ -224,7 +224,7 @@ const schema = { name: "CodecPrivate", type: "b" }, - a3: { + "a3": { name: "SimpleBlock", type: "b" }, @@ -244,7 +244,7 @@ const schema = { name: "Info", type: "m" }, - e1: { + "e1": { name: "Audio", type: "m" }, diff --git a/package.json b/package.json index 016cf72c..6e35cacd 100644 --- a/package.json +++ b/package.json @@ -19,10 +19,8 @@ "node": ">=18.0.0" }, "scripts": { - "lint:js": "eslint -c .eslintrc.yml lib examples *.js", - "lint:js:fix": "eslint -c .eslintrc.yml lib examples *.js --fix && echo \"\u001b[1m\u001b[32mOK\u001b[39m\u001b[22m\" || echo \"\u001b[1m\u001b[31mNot OK\u001b[39m\u001b[22m\"", - "lint:ts": "eslint -c .eslintrc.ts.yml *.ts", - "lint:ts:fix": "eslint -c .eslintrc.ts.yml *.ts --fix && echo \"\u001b[1m\u001b[32mOK\u001b[39m\u001b[22m\" || echo \"\u001b[1m\u001b[31mNot OK\u001b[39m\u001b[22m\"" + "lint": "eslint .", + "lint:fix": "eslint . --fix && echo \"\u001b[1m\u001b[32mOK\u001b[39m\u001b[22m\" || echo \"\u001b[1m\u001b[31mNot OK\u001b[39m\u001b[22m\"" }, "repository": { "type": "git", @@ -45,13 +43,16 @@ "ws": "^8.18.0" }, "devDependencies": { + "@eslint/js": "^8.57.0", + "@stylistic/eslint-plugin": "^2.4.0", "@types/node": "^18.19.41", "@types/ws": "^8.5.11", - "@typescript-eslint/eslint-plugin": "^7.16.1", - "@typescript-eslint/parser": "^7.16.1", "eslint": "^8.57.0", + "eslint-plugin-jsdoc": "^48.10.2", "eslint-plugin-sort-class-members": "^1.20.0", - "typescript": "^5.5.3" + "globals": "^15.8.0", + "typescript": "^5.5.3", + "typescript-eslint": "^7.18.0" }, "optionalDependencies": { "opusscript": "^0.1.1",