mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
docs(*): add links to Discord's API objects & data (#5862)
This commit is contained in:
@@ -193,7 +193,7 @@ class ApplicationCommandManager extends BaseManager {
|
||||
/**
|
||||
* Transforms an {@link ApplicationCommandData} object into something that can be used with the API.
|
||||
* @param {ApplicationCommandData} command The command to transform
|
||||
* @returns {Object}
|
||||
* @returns {APIApplicationCommand}
|
||||
* @private
|
||||
*/
|
||||
static transformCommand(command) {
|
||||
@@ -326,7 +326,7 @@ class ApplicationCommandManager extends BaseManager {
|
||||
* Transforms an {@link ApplicationCommandPermissionData} object into something that can be used with the API.
|
||||
* @param {ApplicationCommandPermissionData} permissions The permissions to transform
|
||||
* @param {boolean} [received] Whether these permissions have been received from Discord
|
||||
* @returns {Object}
|
||||
* @returns {APIApplicationCommandPermissions}
|
||||
* @private
|
||||
*/
|
||||
static transformPermissions(permissions, received) {
|
||||
@@ -342,3 +342,8 @@ class ApplicationCommandManager extends BaseManager {
|
||||
}
|
||||
|
||||
module.exports = ApplicationCommandManager;
|
||||
|
||||
/**
|
||||
* @external APIApplicationCommandPermissions
|
||||
* @see {@link https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissions}
|
||||
*/
|
||||
|
||||
@@ -47,7 +47,7 @@ class DiscordAPIError extends Error {
|
||||
|
||||
/**
|
||||
* Flattens an errors object returned from the API into an array.
|
||||
* @param {Object} obj Discord errors object
|
||||
* @param {APIError} obj Discord errors object
|
||||
* @param {string} [key] Used internally to determine key names of nested fields
|
||||
* @returns {string[]}
|
||||
* @private
|
||||
@@ -75,3 +75,8 @@ class DiscordAPIError extends Error {
|
||||
}
|
||||
|
||||
module.exports = DiscordAPIError;
|
||||
|
||||
/**
|
||||
* @external APIError
|
||||
* @see {@link https://discord.com/developers/docs/reference#error-messages}
|
||||
*/
|
||||
|
||||
@@ -31,13 +31,20 @@ class APIMessage {
|
||||
|
||||
/**
|
||||
* Data sendable to the API
|
||||
* @type {?Object}
|
||||
* @type {?APIMessageRaw}
|
||||
*/
|
||||
this.data = null;
|
||||
|
||||
/**
|
||||
* @typedef {Object} MessageFile
|
||||
* @property {Buffer|string|Stream} attachment The original attachment that generated this file
|
||||
* @property {string} name The name of this file
|
||||
* @property {Buffer|Stream} file The file to be sent to the API
|
||||
*/
|
||||
|
||||
/**
|
||||
* Files sendable to the API
|
||||
* @type {?Object[]}
|
||||
* @type {?MessageFile[]}
|
||||
*/
|
||||
this.files = null;
|
||||
}
|
||||
@@ -259,7 +266,7 @@ class APIMessage {
|
||||
/**
|
||||
* Resolves a single file into an object sendable to the API.
|
||||
* @param {BufferResolvable|Stream|FileOptions|MessageAttachment} fileLike Something that could be resolved to a file
|
||||
* @returns {Object}
|
||||
* @returns {MessageFile}
|
||||
*/
|
||||
static async resolveFile(fileLike) {
|
||||
let attachment;
|
||||
@@ -313,3 +320,8 @@ module.exports = APIMessage;
|
||||
* @typedef {TextChannel|DMChannel|User|GuildMember|Webhook|WebhookClient|Interaction|InteractionWebhook|
|
||||
* Message|MessageManager} MessageTarget
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external APIMessageRaw
|
||||
* @see {@link https://discord.com/developers/docs/resources/channel#message-object}
|
||||
*/
|
||||
|
||||
@@ -206,13 +206,13 @@ class ApplicationCommand extends Base {
|
||||
* Transforms an {@link ApplicationCommandOptionData} object into something that can be used with the API.
|
||||
* @param {ApplicationCommandOptionData} option The option to transform
|
||||
* @param {boolean} [received] Whether this option has been received from Discord
|
||||
* @returns {Object}
|
||||
* @returns {APIApplicationCommandOption}
|
||||
* @private
|
||||
*/
|
||||
static transformOption(option, received) {
|
||||
const stringType = typeof option.type === 'string' ? option.type : ApplicationCommandOptionTypes[option.type];
|
||||
return {
|
||||
type: typeof option.type === 'number' && !received ? option.type : ApplicationCommandOptionTypes[option.type],
|
||||
type: typeof option.type === 'number' && !received ? option.type : stringType,
|
||||
name: option.name,
|
||||
description: option.description,
|
||||
required:
|
||||
@@ -224,3 +224,13 @@ class ApplicationCommand extends Base {
|
||||
}
|
||||
|
||||
module.exports = ApplicationCommand;
|
||||
|
||||
/**
|
||||
* @external APIApplicationCommand
|
||||
* @see {@link https://discord.com/developers/docs/interactions/slash-commands#applicationcommand}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external APIApplicationCommandOption
|
||||
* @see {@link https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoption}
|
||||
*/
|
||||
|
||||
@@ -165,3 +165,8 @@ class Channel extends Base {
|
||||
}
|
||||
|
||||
module.exports = Channel;
|
||||
|
||||
/**
|
||||
* @external APIChannel
|
||||
* @see {@link https://discord.com/developers/docs/resources/channel#channel-object}
|
||||
*/
|
||||
|
||||
@@ -7,7 +7,7 @@ const { ActivityTypes, OPCodes } = require('../util/Constants');
|
||||
class ClientPresence extends Presence {
|
||||
/**
|
||||
* @param {Client} client The instantiating client
|
||||
* @param {Object} [data={}] The data for the client presence
|
||||
* @param {APIPresence} [data={}] The data for the client presence
|
||||
*/
|
||||
constructor(client, data = {}) {
|
||||
super(client, Object.assign(data, { status: data.status || 'online', user: { id: null } }));
|
||||
|
||||
@@ -48,7 +48,7 @@ class ClientUser extends Structures.get('User') {
|
||||
|
||||
/**
|
||||
* Edits the logged in client.
|
||||
* @param {Object} data The new data
|
||||
* @param {APIModifyClientData} data The new data
|
||||
* @param {string} [data.username] The new username
|
||||
* @param {BufferResolvable|Base64Resolvable} [data.avatar] The new avatar
|
||||
*/
|
||||
@@ -143,8 +143,7 @@ class ClientUser extends Structures.get('User') {
|
||||
|
||||
/**
|
||||
* Options for setting an activity.
|
||||
* @typedef ActivityOptions
|
||||
* @type {Object}
|
||||
* @typedef {Object} ActivityOptions
|
||||
* @property {string} [name] Name of the activity
|
||||
* @property {string} [url] Twitch / YouTube stream URL
|
||||
* @property {ActivityType|number} [type] Type of the activity
|
||||
@@ -179,3 +178,8 @@ class ClientUser extends Structures.get('User') {
|
||||
}
|
||||
|
||||
module.exports = ClientUser;
|
||||
|
||||
/**
|
||||
* @external APIModifyClientData
|
||||
* @see {@link https://discord.com/developers/docs/resources/user#modify-current-user-json-params}
|
||||
*/
|
||||
|
||||
@@ -89,15 +89,15 @@ class CommandInteraction extends Interaction {
|
||||
* @property {Collection<string, CommandInteractionOption>} [options] Additional options if this option is a
|
||||
* subcommand (group)
|
||||
* @property {User} [user] The resolved user
|
||||
* @property {GuildMember|Object} [member] The resolved member
|
||||
* @property {GuildChannel|Object} [channel] The resolved channel
|
||||
* @property {Role|Object} [role] The resolved role
|
||||
* @property {GuildMember|APIGuildMember} [member] The resolved member
|
||||
* @property {GuildChannel|APIChannel} [channel] The resolved channel
|
||||
* @property {Role|APIRole} [role] The resolved role
|
||||
*/
|
||||
|
||||
/**
|
||||
* Transforms an option received from the API.
|
||||
* @param {Object} option The received option
|
||||
* @param {Object} resolved The resolved interaction data
|
||||
* @param {APIApplicationCommandOption} option The received option
|
||||
* @param {APIApplicationCommandOptionResolved} resolved The resolved interaction data
|
||||
* @returns {CommandInteractionOption}
|
||||
* @private
|
||||
*/
|
||||
@@ -127,8 +127,8 @@ class CommandInteraction extends Interaction {
|
||||
|
||||
/**
|
||||
* Creates a collection of options from the received options array.
|
||||
* @param {Object[]} options The received options
|
||||
* @param {Object} resolved The resolved interaction data
|
||||
* @param {APIApplicationCommandOption[]} options The received options
|
||||
* @param {APIApplicationCommandOptionResolved} resolved The resolved interaction data
|
||||
* @returns {Collection<string, CommandInteractionOption>}
|
||||
* @private
|
||||
*/
|
||||
@@ -154,3 +154,9 @@ class CommandInteraction extends Interaction {
|
||||
InteractionResponses.applyToClass(CommandInteraction, ['deferUpdate', 'update']);
|
||||
|
||||
module.exports = CommandInteraction;
|
||||
|
||||
/* eslint-disable max-len */
|
||||
/**
|
||||
* @external APIApplicationCommandOptionResolved
|
||||
* @see {@link https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondataresolved}
|
||||
*/
|
||||
|
||||
@@ -12,7 +12,7 @@ const MessageManager = require('../managers/MessageManager');
|
||||
class DMChannel extends Channel {
|
||||
/**
|
||||
* @param {Client} client The instantiating client
|
||||
* @param {Object} data The data for the DM channel
|
||||
* @param {APIChannel} data The data for the DM channel
|
||||
*/
|
||||
constructor(client, data) {
|
||||
super(client, data);
|
||||
|
||||
@@ -5,7 +5,7 @@ const SnowflakeUtil = require('../util/SnowflakeUtil');
|
||||
|
||||
/**
|
||||
* Represents raw emoji data from the API
|
||||
* @typedef {Object} RawEmoji
|
||||
* @typedef {APIEmoji} RawEmoji
|
||||
* @property {?Snowflake} id ID of this emoji
|
||||
* @property {?string} name Name of this emoji
|
||||
* @property {?boolean} animated Whether this emoji is animated
|
||||
@@ -110,3 +110,8 @@ class Emoji extends Base {
|
||||
}
|
||||
|
||||
module.exports = Emoji;
|
||||
|
||||
/**
|
||||
* @external APIEmoji
|
||||
* @see {@link https://discord.com/developers/docs/resources/emoji#emoji-object}
|
||||
*/
|
||||
|
||||
@@ -1389,3 +1389,8 @@ class Guild extends AnonymousGuild {
|
||||
}
|
||||
|
||||
module.exports = Guild;
|
||||
|
||||
/**
|
||||
* @external APIGuild
|
||||
* @see {@link https://discord.com/developers/docs/resources/guild#guild-object}
|
||||
*/
|
||||
|
||||
@@ -9,7 +9,7 @@ const Base = require('./Base');
|
||||
class GuildBan extends Base {
|
||||
/**
|
||||
* @param {Client} client The instantiating client
|
||||
* @param {Object} data The data for the ban
|
||||
* @param {APIBanData} data The data for the ban
|
||||
* @param {Guild} guild The guild in which the ban is
|
||||
*/
|
||||
constructor(client, data, guild) {
|
||||
@@ -61,3 +61,8 @@ class GuildBan extends Base {
|
||||
}
|
||||
|
||||
module.exports = GuildBan;
|
||||
|
||||
/**
|
||||
* @external APIBanData
|
||||
* @see {@link https://discord.com/developers/docs/resources/guild#create-guild-ban-json-params}
|
||||
*/
|
||||
|
||||
@@ -25,7 +25,7 @@ const Util = require('../util/Util');
|
||||
class GuildChannel extends Channel {
|
||||
/**
|
||||
* @param {Guild} guild The guild the guild channel is part of
|
||||
* @param {Object} data The data for the guild channel
|
||||
* @param {APIChannel} data The data for the guild channel
|
||||
*/
|
||||
constructor(guild, data) {
|
||||
super(guild.client, data);
|
||||
|
||||
@@ -12,7 +12,7 @@ const Permissions = require('../util/Permissions');
|
||||
class GuildEmoji extends BaseGuildEmoji {
|
||||
/**
|
||||
* @param {Client} client The instantiating client
|
||||
* @param {Object} data The data for the guild emoji
|
||||
* @param {APIEmoji} data The data for the guild emoji
|
||||
* @param {Guild} guild The guild the guild emoji is part of
|
||||
*/
|
||||
constructor(client, data, guild) {
|
||||
@@ -151,7 +151,7 @@ class GuildEmoji extends BaseGuildEmoji {
|
||||
|
||||
/**
|
||||
* Whether this emoji is the same as another one.
|
||||
* @param {GuildEmoji|Object} other The emoji to compare it to
|
||||
* @param {GuildEmoji|APIEmoji} other The emoji to compare it to
|
||||
* @returns {boolean} Whether the emoji is equal to the given emoji or not
|
||||
*/
|
||||
equals(other) {
|
||||
|
||||
@@ -15,7 +15,7 @@ let Structures;
|
||||
class GuildMember extends Base {
|
||||
/**
|
||||
* @param {Client} client The instantiating client
|
||||
* @param {Object} data The data for the guild member
|
||||
* @param {APIGuildMember} data The data for the guild member
|
||||
* @param {Guild} guild The guild the member is part of
|
||||
*/
|
||||
constructor(client, data, guild) {
|
||||
@@ -397,3 +397,8 @@ class GuildMember extends Base {
|
||||
TextBasedChannel.applyToClass(GuildMember);
|
||||
|
||||
module.exports = GuildMember;
|
||||
|
||||
/**
|
||||
* @external APIGuildMember
|
||||
* @see {@link https://discord.com/developers/docs/resources/guild#guild-member-object}
|
||||
*/
|
||||
|
||||
@@ -11,7 +11,7 @@ const DataResolver = require('../util/DataResolver');
|
||||
class GuildTemplate extends Base {
|
||||
/**
|
||||
* @param {Client} client The instantiating client
|
||||
* @param {Object} data The raw data for the template
|
||||
* @param {APIGuildTemplate} data The raw data for the template
|
||||
*/
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
@@ -20,7 +20,7 @@ class GuildTemplate extends Base {
|
||||
|
||||
/**
|
||||
* Builds or updates the template with the provided data.
|
||||
* @param {Object} data The raw data for the template
|
||||
* @param {APIGuildTemplate} data The raw data for the template
|
||||
* @returns {GuildTemplate}
|
||||
* @private
|
||||
*/
|
||||
@@ -81,8 +81,7 @@ class GuildTemplate extends Base {
|
||||
|
||||
/**
|
||||
* The data of the guild that this template would create
|
||||
* @type {Object}
|
||||
* @see {@link https://discord.com/developers/docs/resources/guild#guild-resource}
|
||||
* @type {APIGuild}
|
||||
*/
|
||||
this.serializedGuild = data.serialized_source_guild;
|
||||
|
||||
@@ -234,3 +233,9 @@ class GuildTemplate extends Base {
|
||||
GuildTemplate.GUILD_TEMPLATES_PATTERN = /discord(?:app)?\.(?:com\/template|new)\/([\w-]{2,255})/gi;
|
||||
|
||||
module.exports = GuildTemplate;
|
||||
|
||||
/* eslint-disable max-len */
|
||||
/**
|
||||
* @external APIGuildTemplate
|
||||
* @see {@link https://discord.com/developers/docs/resources/guild-template#guild-template-object-guild-template-structure}
|
||||
*/
|
||||
|
||||
@@ -58,7 +58,7 @@ class Interaction extends Base {
|
||||
|
||||
/**
|
||||
* If this interaction was sent in a guild, the member which sent it
|
||||
* @type {?GuildMember|Object}
|
||||
* @type {?GuildMember|APIGuildMember}
|
||||
*/
|
||||
this.member = data.member ? this.guild?.members.add(data.member) ?? data.member : null;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class InteractionWebhook {
|
||||
/**
|
||||
* Sends a message with this webhook.
|
||||
* @param {string|APIMessage|InteractionReplyOptions} options The content for the reply
|
||||
* @returns {Promise<Message|Object>}
|
||||
* @returns {Promise<Message|APIMessageRaw>}
|
||||
*/
|
||||
send() {}
|
||||
fetchMessage() {}
|
||||
|
||||
@@ -26,7 +26,7 @@ const Util = require('../util/Util');
|
||||
class Message extends Base {
|
||||
/**
|
||||
* @param {Client} client The instantiating client
|
||||
* @param {Object} data The data for the message
|
||||
* @param {APIMessageRaw} data The data for the message
|
||||
* @param {TextChannel|DMChannel|NewsChannel} channel The channel the message was sent in
|
||||
*/
|
||||
constructor(client, data, channel) {
|
||||
@@ -283,7 +283,7 @@ class Message extends Base {
|
||||
|
||||
/**
|
||||
* Updates the message and returns the old message.
|
||||
* @param {Object} data Raw Discord message update data
|
||||
* @param {APIMessageRaw} data Raw Discord message update data
|
||||
* @returns {Message}
|
||||
* @private
|
||||
*/
|
||||
@@ -537,7 +537,7 @@ class Message extends Base {
|
||||
* Options that can be passed into {@link Message#edit}.
|
||||
* @typedef {Object} MessageEditOptions
|
||||
* @property {?string} [content] Content to be edited
|
||||
* @property {MessageEmbed[]|Object[]} [embeds] Embeds to be added/edited
|
||||
* @property {MessageEmbed[]|APIEmbed[]} [embeds] Embeds to be added/edited
|
||||
* @property {string|boolean} [code] Language for optional codeblock formatting to apply
|
||||
* @property {MessageMentionOptions} [allowedMentions] Which mentions should be parsed from the message content
|
||||
* @property {MessageFlags} [flags] Which flags to set for the message. Only `SUPPRESS_EMBEDS` can be edited.
|
||||
@@ -724,7 +724,7 @@ class Message extends Base {
|
||||
* without checking all the properties, use `message.id === message2.id`, which is much more efficient. This
|
||||
* method allows you to see if there are differences in content, embeds, attachments, nonce and tts properties.
|
||||
* @param {Message} message The message to compare it to
|
||||
* @param {Object} rawData Raw data passed through the WebSocket about this message
|
||||
* @param {APIMessageRaw} rawData Raw data passed through the WebSocket about this message
|
||||
* @returns {boolean}
|
||||
*/
|
||||
equals(message, rawData) {
|
||||
|
||||
@@ -74,7 +74,7 @@ class MessageActionRow extends BaseMessageComponent {
|
||||
|
||||
/**
|
||||
* Transforms the action row to a plain object.
|
||||
* @returns {Object} The raw data of this action row
|
||||
* @returns {APIMessageComponent} The raw data of this action row
|
||||
*/
|
||||
toJSON() {
|
||||
return {
|
||||
@@ -85,3 +85,8 @@ class MessageActionRow extends BaseMessageComponent {
|
||||
}
|
||||
|
||||
module.exports = MessageActionRow;
|
||||
|
||||
/**
|
||||
* @external APIMessageComponent
|
||||
* @see {@link https://discord.com/developers/docs/interactions/message-components#component-object}
|
||||
*/
|
||||
|
||||
@@ -9,7 +9,7 @@ class MessageAttachment {
|
||||
/**
|
||||
* @param {BufferResolvable|Stream} attachment The file
|
||||
* @param {string} [name=null] The name of the file, if any
|
||||
* @param {Object} [data] Extra data
|
||||
* @param {APIAttachment} [data] Extra data
|
||||
*/
|
||||
constructor(attachment, name = null, data) {
|
||||
this.attachment = attachment;
|
||||
@@ -102,3 +102,8 @@ class MessageAttachment {
|
||||
}
|
||||
|
||||
module.exports = MessageAttachment;
|
||||
|
||||
/**
|
||||
* @external APIAttachment
|
||||
* @see {@link https://discord.com/developers/docs/resources/channel#attachment-object}
|
||||
*/
|
||||
|
||||
@@ -130,7 +130,7 @@ class MessageButton extends BaseMessageComponent {
|
||||
|
||||
/**
|
||||
* Transforms the button to a plain object.
|
||||
* @returns {Object} The raw data of this button
|
||||
* @returns {APIMessageComponent} The raw data of this button
|
||||
*/
|
||||
toJSON() {
|
||||
return {
|
||||
|
||||
@@ -16,7 +16,7 @@ class MessageComponentInteraction extends Interaction {
|
||||
|
||||
/**
|
||||
* The message to which the component was attached
|
||||
* @type {?Message|Object}
|
||||
* @type {?(Message|APIMessageRaw)}
|
||||
*/
|
||||
this.message = data.message ? this.channel?.messages.add(data.message) ?? data.message : null;
|
||||
|
||||
|
||||
@@ -387,7 +387,7 @@ class MessageEmbed {
|
||||
|
||||
/**
|
||||
* Transforms the embed to a plain object.
|
||||
* @returns {Object} The raw data of this embed
|
||||
* @returns {APIEmbed} The raw data of this embed
|
||||
*/
|
||||
toJSON() {
|
||||
return {
|
||||
@@ -457,3 +457,8 @@ class MessageEmbed {
|
||||
}
|
||||
|
||||
module.exports = MessageEmbed;
|
||||
|
||||
/**
|
||||
* @external APIEmbed
|
||||
* @see {@link https://discord.com/developers/docs/resources/channel#embed-object}
|
||||
*/
|
||||
|
||||
@@ -11,7 +11,7 @@ const Util = require('../util/Util');
|
||||
class MessageReaction {
|
||||
/**
|
||||
* @param {Client} client The instantiating client
|
||||
* @param {Object} data The data for the message reaction
|
||||
* @param {APIReaction} data The data for the message reaction
|
||||
* @param {Message} message The message the reaction refers to
|
||||
*/
|
||||
constructor(client, data, message) {
|
||||
@@ -134,3 +134,8 @@ class MessageReaction {
|
||||
}
|
||||
|
||||
module.exports = MessageReaction;
|
||||
|
||||
/**
|
||||
* @external APIReaction
|
||||
* @see {@link https://discord.com/developers/docs/resources/channel#reaction-object}
|
||||
*/
|
||||
|
||||
@@ -118,9 +118,7 @@ class PermissionOverwrites {
|
||||
/**
|
||||
* Resolves bitfield permissions overwrites from an object.
|
||||
* @param {PermissionOverwriteOptions} options The options for the update
|
||||
* @param {Object} initialPermissions The initial permissions
|
||||
* @param {PermissionResolvable} initialPermissions.allow Initial allowed permissions
|
||||
* @param {PermissionResolvable} initialPermissions.deny Initial denied permissions
|
||||
* @param {ResolvedOverwriteOptions} initialPermissions The initial permissions
|
||||
* @returns {ResolvedOverwriteOptions}
|
||||
*/
|
||||
static resolveOverwriteOptions(options, { allow, deny } = {}) {
|
||||
|
||||
@@ -35,7 +35,7 @@ const Util = require('../util/Util');
|
||||
class Presence {
|
||||
/**
|
||||
* @param {Client} client The instantiating client
|
||||
* @param {Object} [data={}] The data for the presence
|
||||
* @param {APIPresence} [data={}] The data for the presence
|
||||
*/
|
||||
constructor(client, data = {}) {
|
||||
/**
|
||||
@@ -373,3 +373,9 @@ class RichPresenceAssets {
|
||||
exports.Presence = Presence;
|
||||
exports.Activity = Activity;
|
||||
exports.RichPresenceAssets = RichPresenceAssets;
|
||||
|
||||
/* eslint-disable max-len */
|
||||
/**
|
||||
* @external APIPresence
|
||||
* @see {@link https://discord.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields}
|
||||
*/
|
||||
|
||||
@@ -13,7 +13,7 @@ const Util = require('../util/Util');
|
||||
class Role extends Base {
|
||||
/**
|
||||
* @param {Client} client The instantiating client
|
||||
* @param {Object} data The data for the role
|
||||
* @param {APIRole} data The data for the role
|
||||
* @param {Guild} guild The guild the role is part of
|
||||
*/
|
||||
constructor(client, data, guild) {
|
||||
@@ -424,3 +424,8 @@ class Role extends Base {
|
||||
}
|
||||
|
||||
module.exports = Role;
|
||||
|
||||
/**
|
||||
* @external APIRole
|
||||
* @see {@link https://discord.com/developers/docs/topics/permissions#role-object}
|
||||
*/
|
||||
|
||||
@@ -15,7 +15,7 @@ const DataResolver = require('../util/DataResolver');
|
||||
class TextChannel extends GuildChannel {
|
||||
/**
|
||||
* @param {Guild} guild The guild the text channel is part of
|
||||
* @param {Object} data The data for the text channel
|
||||
* @param {APIChannel} data The data for the text channel
|
||||
*/
|
||||
constructor(guild, data) {
|
||||
super(guild, data);
|
||||
|
||||
@@ -16,7 +16,7 @@ let Structures;
|
||||
class User extends Base {
|
||||
/**
|
||||
* @param {Client} client The instantiating client
|
||||
* @param {Object} data The data for the user
|
||||
* @param {APIUser} data The data for the user
|
||||
*/
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
@@ -333,3 +333,8 @@ class User extends Base {
|
||||
TextBasedChannel.applyToClass(User);
|
||||
|
||||
module.exports = User;
|
||||
|
||||
/**
|
||||
* @external APIUser
|
||||
* @see {@link https://discord.com/developers/docs/resources/user#user-object}
|
||||
*/
|
||||
|
||||
@@ -9,7 +9,7 @@ const { Error, TypeError } = require('../errors');
|
||||
class VoiceState extends Base {
|
||||
/**
|
||||
* @param {Guild} guild The guild the voice state is part of
|
||||
* @param {Object} data The data for the voice state
|
||||
* @param {APIVoiceState} data The data for the voice state
|
||||
*/
|
||||
constructor(guild, data) {
|
||||
super(guild.client);
|
||||
@@ -233,3 +233,8 @@ class VoiceState extends Base {
|
||||
}
|
||||
|
||||
module.exports = VoiceState;
|
||||
|
||||
/**
|
||||
* @external APIVoiceState
|
||||
* @see {@link https://discord.com/developers/docs/resources/voice#voice-state-object}
|
||||
*/
|
||||
|
||||
@@ -68,13 +68,13 @@ class Webhook {
|
||||
|
||||
/**
|
||||
* The owner of the webhook
|
||||
* @type {?User|Object}
|
||||
* @type {?User|APIUser}
|
||||
*/
|
||||
this.owner = data.user ? this.client.users?.add(data.user) ?? data.user : null;
|
||||
|
||||
/**
|
||||
* The source guild of the webhook
|
||||
* @type {?Guild|Object}
|
||||
* @type {?Guild|APIGuild}
|
||||
*/
|
||||
this.sourceGuild = data.source_guild
|
||||
? this.client.guilds?.add(data.source_guild, false) ?? data.source_guild
|
||||
@@ -82,7 +82,7 @@ class Webhook {
|
||||
|
||||
/**
|
||||
* The source channel of the webhook
|
||||
* @type {?Channel|Object}
|
||||
* @type {?Channel|APIChannel}
|
||||
*/
|
||||
this.sourceChannel = this.client.channels?.resolve(data.source_channel?.id) ?? data.source_channel ?? null;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ class Webhook {
|
||||
/**
|
||||
* Options that can be passed into editMessage.
|
||||
* @typedef {Object} WebhookEditMessageOptions
|
||||
* @property {MessageEmbed[]|Object[]} [embeds] See {@link WebhookMessageOptions#embeds}
|
||||
* @property {MessageEmbed[]|APIEmbed[]} [embeds] See {@link WebhookMessageOptions#embeds}
|
||||
* @property {string} [content] See {@link BaseMessageOptions#content}
|
||||
* @property {FileOptions[]|BufferResolvable[]|MessageAttachment[]} [files] See {@link BaseMessageOptions#files}
|
||||
* @property {MessageMentionOptions} [allowedMentions] See {@link BaseMessageOptions#allowedMentions}
|
||||
@@ -108,7 +108,7 @@ class Webhook {
|
||||
/**
|
||||
* Sends a message with this webhook.
|
||||
* @param {string|APIMessage|WebhookMessageOptions} options The options to provide
|
||||
* @returns {Promise<Message|Object>}
|
||||
* @returns {Promise<Message|APIMessageRaw>}
|
||||
* @example
|
||||
* // Send a basic message
|
||||
* webhook.send('hello!')
|
||||
@@ -195,6 +195,7 @@ class Webhook {
|
||||
* 'ts': Date.now() / 1000
|
||||
* }]
|
||||
* }).catch(console.error);
|
||||
* @see {@link https://api.slack.com/messaging/webhooks}
|
||||
*/
|
||||
sendSlackMessage(body) {
|
||||
if (!this.token) throw new Error('WEBHOOK_TOKEN_UNAVAILABLE');
|
||||
@@ -243,7 +244,7 @@ class Webhook {
|
||||
* Gets a message that was sent by this webhook.
|
||||
* @param {Snowflake|'@original'} message The ID of the message to fetch
|
||||
* @param {boolean} [cache=true] Whether to cache the message
|
||||
* @returns {Promise<Message|Object>} Returns the raw message data if the webhook was instantiated as a
|
||||
* @returns {Promise<Message|APIMessageRaw>} Returns the raw message data if the webhook was instantiated as a
|
||||
* {@link WebhookClient} or if the channel is uncached, otherwise a {@link Message} will be returned
|
||||
*/
|
||||
async fetchMessage(message, cache = true) {
|
||||
@@ -257,7 +258,7 @@ class Webhook {
|
||||
* Edits a message that was sent by this webhook.
|
||||
* @param {MessageResolvable|'@original'} message The message to edit
|
||||
* @param {string|APIMessage|WebhookEditMessageOptions} options The options to provide
|
||||
* @returns {Promise<Message|Object>} Returns the raw message data if the webhook was instantiated as a
|
||||
* @returns {Promise<Message|APIMessageRaw>} Returns the raw message data if the webhook was instantiated as a
|
||||
* {@link WebhookClient} or if the channel is uncached, otherwise a {@link Message} will be returned
|
||||
*/
|
||||
async editMessage(message, options) {
|
||||
|
||||
@@ -91,7 +91,7 @@ class InteractionResponses {
|
||||
/**
|
||||
* Fetches the initial reply to this interaction.
|
||||
* @see Webhook#fetchMessage
|
||||
* @returns {Promise<Message|Object>}
|
||||
* @returns {Promise<Message|APIMessageRaw>}
|
||||
* @example
|
||||
* // Fetch the reply to this interaction
|
||||
* interaction.fetchReply()
|
||||
@@ -107,7 +107,7 @@ class InteractionResponses {
|
||||
* Edits the initial reply to this interaction.
|
||||
* @see Webhook#editMessage
|
||||
* @param {string|APIMessage|WebhookEditMessageOptions} options The new options for the message
|
||||
* @returns {Promise<Message|Object>}
|
||||
* @returns {Promise<Message|APIMessageRaw>}
|
||||
* @example
|
||||
* // Edit the reply to this interaction
|
||||
* interaction.editReply('New content')
|
||||
@@ -139,7 +139,7 @@ class InteractionResponses {
|
||||
/**
|
||||
* Send a follow-up message to this interaction.
|
||||
* @param {string|APIMessage|InteractionReplyOptions} options The options for the reply
|
||||
* @returns {Promise<Message|Object>}
|
||||
* @returns {Promise<Message|APIMessageRaw>}
|
||||
*/
|
||||
followUp(options) {
|
||||
return this.webhook.send(options);
|
||||
|
||||
@@ -57,7 +57,7 @@ class TextBasedChannel {
|
||||
* @property {boolean} [tts=false] Whether or not the message should be spoken aloud
|
||||
* @property {string} [nonce=''] The nonce for the message
|
||||
* @property {string} [content=''] The content for the message
|
||||
* @property {MessageEmbed[]|Object[]} [embeds] The embeds for the message
|
||||
* @property {MessageEmbed[]|APIEmbed[]} [embeds] The embeds for the message
|
||||
* (see [here](https://discord.com/developers/docs/resources/channel#embed-object) for more details)
|
||||
* @property {MessageMentionOptions} [allowedMentions] Which mentions should be parsed from the message content
|
||||
* (see [here](https://discord.com/developers/docs/resources/channel#allowed-mentions-object) for more details)
|
||||
|
||||
@@ -273,7 +273,7 @@ class Util {
|
||||
* * A URL-encoded UTF-8 emoji (no ID)
|
||||
* * A Discord custom emoji (`<:name:id>` or `<a:name:id>`)
|
||||
* @param {string} text Emoji string to parse
|
||||
* @returns {Object} Object with `animated`, `name`, and `id` properties
|
||||
* @returns {APIEmoji} Object with `animated`, `name`, and `id` properties
|
||||
* @private
|
||||
*/
|
||||
static parseEmoji(text) {
|
||||
@@ -483,7 +483,7 @@ class Util {
|
||||
* @param {Collection<string, Channel|Role>} sorted A collection of the objects sorted properly
|
||||
* @param {APIRouter} route Route to call PATCH on
|
||||
* @param {string} [reason] Reason for the change
|
||||
* @returns {Promise<Object[]>} Updated item list, with `id` and `position` properties
|
||||
* @returns {Promise<Channel[]|Role[]>} Updated item list, with `id` and `position` properties
|
||||
* @private
|
||||
*/
|
||||
static setPosition(item, position, relative, sorted, route, reason) {
|
||||
|
||||
Reference in New Issue
Block a user