mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 11:03:30 +01:00
feat(StageChannel): add messages (#9134)
* feat(StageChannel): add messages * fix: missing implements jsdoc * Apply suggestions from code review Co-authored-by: MateoDeveloper <79017590+Mateo-tem@users.noreply.github.com> * Update packages/discord.js/src/util/Constants.js Co-authored-by: MateoDeveloper <79017590+Mateo-tem@users.noreply.github.com> * feat: use common class * Apply suggestions from code review Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> * feat: add stage to text based channels + fix webhook.channel typings * fix: some fixes * Update packages/discord.js/src/structures/BaseGuildVoiceChannel.js Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com> * Update packages/discord.js/src/structures/VoiceChannel.js Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> * Update packages/discord.js/src/structures/interfaces/TextBasedChannel.js Co-authored-by: Aura Román <kyradiscord@gmail.com> * Update packages/discord.js/src/structures/BaseGuildVoiceChannel.js Co-authored-by: space <spaceeec@yahoo.com> --------- Co-authored-by: MateoDeveloper <79017590+Mateo-tem@users.noreply.github.com> Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com> Co-authored-by: Aura Román <kyradiscord@gmail.com> Co-authored-by: space <spaceeec@yahoo.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -10,7 +10,8 @@ class WebhooksUpdate extends Action {
|
|||||||
/**
|
/**
|
||||||
* Emitted whenever a channel has its webhooks changed.
|
* Emitted whenever a channel has its webhooks changed.
|
||||||
* @event Client#webhookUpdate
|
* @event Client#webhookUpdate
|
||||||
* @param {TextChannel|NewsChannel|VoiceChannel|ForumChannel} channel The channel that had a webhook update
|
* @param {TextChannel|NewsChannel|VoiceChannel|StageChannel|ForumChannel} channel
|
||||||
|
* The channel that had a webhook update
|
||||||
*/
|
*/
|
||||||
if (channel) client.emit(Events.WebhooksUpdate, channel);
|
if (channel) client.emit(Events.WebhooksUpdate, channel);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ class GuildChannelManager extends CachedManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {ChannelWebhookCreateOptions} WebhookCreateOptions
|
* @typedef {ChannelWebhookCreateOptions} WebhookCreateOptions
|
||||||
* @property {TextChannel|NewsChannel|VoiceChannel|ForumChannel|Snowflake} channel
|
* @property {TextChannel|NewsChannel|VoiceChannel|StageChannel|ForumChannel|Snowflake} channel
|
||||||
* The channel to create the webhook for
|
* The channel to create the webhook for
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,32 @@
|
|||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
const { PermissionFlagsBits } = require('discord-api-types/v10');
|
const { PermissionFlagsBits } = require('discord-api-types/v10');
|
||||||
const GuildChannel = require('./GuildChannel');
|
const GuildChannel = require('./GuildChannel');
|
||||||
|
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
||||||
|
const MessageManager = require('../managers/MessageManager');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a voice-based guild channel on Discord.
|
* Represents a voice-based guild channel on Discord.
|
||||||
* @extends {GuildChannel}
|
* @extends {GuildChannel}
|
||||||
|
* @implements {TextBasedChannel}
|
||||||
*/
|
*/
|
||||||
class BaseGuildVoiceChannel extends GuildChannel {
|
class BaseGuildVoiceChannel extends GuildChannel {
|
||||||
|
constructor(guild, data, client) {
|
||||||
|
super(guild, data, client, false);
|
||||||
|
/**
|
||||||
|
* A manager of the messages sent to this channel
|
||||||
|
* @type {MessageManager}
|
||||||
|
*/
|
||||||
|
this.messages = new MessageManager(this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the guild considers this channel NSFW
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
this.nsfw = Boolean(data.nsfw);
|
||||||
|
|
||||||
|
this._patch(data);
|
||||||
|
}
|
||||||
|
|
||||||
_patch(data) {
|
_patch(data) {
|
||||||
super._patch(data);
|
super._patch(data);
|
||||||
|
|
||||||
@@ -35,6 +55,40 @@ class BaseGuildVoiceChannel extends GuildChannel {
|
|||||||
*/
|
*/
|
||||||
this.userLimit = data.user_limit;
|
this.userLimit = data.user_limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ('video_quality_mode' in data) {
|
||||||
|
/**
|
||||||
|
* The camera video quality mode of the channel.
|
||||||
|
* @type {?VideoQualityMode}
|
||||||
|
*/
|
||||||
|
this.videoQualityMode = data.video_quality_mode;
|
||||||
|
} else {
|
||||||
|
this.videoQualityMode ??= null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('last_message_id' in data) {
|
||||||
|
/**
|
||||||
|
* The last message id sent in the channel, if one was sent
|
||||||
|
* @type {?Snowflake}
|
||||||
|
*/
|
||||||
|
this.lastMessageId = data.last_message_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('messages' in data) {
|
||||||
|
for (const message of data.messages) this.messages._add(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('rate_limit_per_user' in data) {
|
||||||
|
/**
|
||||||
|
* The rate limit per user (slowmode) for this channel in seconds
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.rateLimitPerUser = data.rate_limit_per_user;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('nsfw' in data) {
|
||||||
|
this.nsfw = data.nsfw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,6 +134,44 @@ class BaseGuildVoiceChannel extends GuildChannel {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an invite to this guild channel.
|
||||||
|
* @param {InviteCreateOptions} [options={}] The options for creating the invite
|
||||||
|
* @returns {Promise<Invite>}
|
||||||
|
* @example
|
||||||
|
* // Create an invite to a channel
|
||||||
|
* channel.createInvite()
|
||||||
|
* .then(invite => console.log(`Created an invite with a code of ${invite.code}`))
|
||||||
|
* .catch(console.error);
|
||||||
|
*/
|
||||||
|
createInvite(options) {
|
||||||
|
return this.guild.invites.create(this.id, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetches a collection of invites to this guild channel.
|
||||||
|
* @param {boolean} [cache=true] Whether to cache the fetched invites
|
||||||
|
* @returns {Promise<Collection<string, Invite>>}
|
||||||
|
*/
|
||||||
|
fetchInvites(cache = true) {
|
||||||
|
return this.guild.invites.fetch({ channelId: this.id, cache });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the bitrate of the channel.
|
||||||
|
* @param {number} bitrate The new bitrate
|
||||||
|
* @param {string} [reason] Reason for changing the channel's bitrate
|
||||||
|
* @returns {Promise<BaseGuildVoiceChannel>}
|
||||||
|
* @example
|
||||||
|
* // Set the bitrate of a voice channel
|
||||||
|
* channel.setBitrate(48_000)
|
||||||
|
* .then(channel => console.log(`Set bitrate to ${channel.bitrate}bps for ${channel.name}`))
|
||||||
|
* .catch(console.error);
|
||||||
|
*/
|
||||||
|
setBitrate(bitrate, reason) {
|
||||||
|
return this.edit({ bitrate, reason });
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the RTC region of the channel.
|
* Sets the RTC region of the channel.
|
||||||
* @param {?string} rtcRegion The new region of the channel. Set to `null` to remove a specific region for the channel
|
* @param {?string} rtcRegion The new region of the channel. Set to `null` to remove a specific region for the channel
|
||||||
@@ -97,28 +189,46 @@ class BaseGuildVoiceChannel extends GuildChannel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an invite to this guild channel.
|
* Sets the user limit of the channel.
|
||||||
* @param {InviteCreateOptions} [options={}] The options for creating the invite
|
* @param {number} userLimit The new user limit
|
||||||
* @returns {Promise<Invite>}
|
* @param {string} [reason] Reason for changing the user limit
|
||||||
|
* @returns {Promise<BaseGuildVoiceChannel>}
|
||||||
* @example
|
* @example
|
||||||
* // Create an invite to a channel
|
* // Set the user limit of a voice channel
|
||||||
* channel.createInvite()
|
* channel.setUserLimit(42)
|
||||||
* .then(invite => console.log(`Created an invite with a code of ${invite.code}`))
|
* .then(channel => console.log(`Set user limit to ${channel.userLimit} for ${channel.name}`))
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
createInvite(options) {
|
setUserLimit(userLimit, reason) {
|
||||||
return this.guild.invites.create(this.id, options);
|
return this.edit({ userLimit, reason });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches a collection of invites to this guild channel.
|
* Sets the camera video quality mode of the channel.
|
||||||
* Resolves with a collection mapping invites by their codes.
|
* @param {VideoQualityMode} videoQualityMode The new camera video quality mode.
|
||||||
* @param {boolean} [cache=true] Whether or not to cache the fetched invites
|
* @param {string} [reason] Reason for changing the camera video quality mode.
|
||||||
* @returns {Promise<Collection<string, Invite>>}
|
* @returns {Promise<BaseGuildVoiceChannel>}
|
||||||
*/
|
*/
|
||||||
fetchInvites(cache = true) {
|
setVideoQualityMode(videoQualityMode, reason) {
|
||||||
return this.guild.invites.fetch({ channelId: this.id, cache });
|
return this.edit({ videoQualityMode, reason });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
||||||
|
/* eslint-disable no-empty-function */
|
||||||
|
get lastMessage() {}
|
||||||
|
send() {}
|
||||||
|
sendTyping() {}
|
||||||
|
createMessageCollector() {}
|
||||||
|
awaitMessages() {}
|
||||||
|
createMessageComponentCollector() {}
|
||||||
|
awaitMessageComponent() {}
|
||||||
|
bulkDelete() {}
|
||||||
|
fetchWebhooks() {}
|
||||||
|
createWebhook() {}
|
||||||
|
setRateLimitPerUser() {}
|
||||||
|
setNSFW() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextBasedChannel.applyToClass(BaseGuildVoiceChannel, true, ['lastPinAt']);
|
||||||
|
|
||||||
module.exports = BaseGuildVoiceChannel;
|
module.exports = BaseGuildVoiceChannel;
|
||||||
|
|||||||
@@ -41,11 +41,11 @@ class StageChannel extends BaseGuildVoiceChannel {
|
|||||||
* Sets a new topic for the guild channel.
|
* Sets a new topic for the guild channel.
|
||||||
* @param {?string} topic The new topic for the guild channel
|
* @param {?string} topic The new topic for the guild channel
|
||||||
* @param {string} [reason] Reason for changing the guild channel's topic
|
* @param {string} [reason] Reason for changing the guild channel's topic
|
||||||
* @returns {Promise<GuildChannel>}
|
* @returns {Promise<StageChannel>}
|
||||||
* @example
|
* @example
|
||||||
* // Set a new channel topic
|
* // Set a new channel topic
|
||||||
* channel.setTopic('needs more rate limiting')
|
* stageChannel.setTopic('needs more rate limiting')
|
||||||
* .then(newChannel => console.log(`Channel's new topic is ${newChannel.topic}`))
|
* .then(channel => console.log(`Channel's new topic is ${channel.topic}`))
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
setTopic(topic, reason) {
|
setTopic(topic, reason) {
|
||||||
@@ -53,6 +53,21 @@ class StageChannel extends BaseGuildVoiceChannel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the bitrate of the channel.
|
||||||
|
* @method setBitrate
|
||||||
|
* @memberof StageChannel
|
||||||
|
* @instance
|
||||||
|
* @param {number} bitrate The new bitrate
|
||||||
|
* @param {string} [reason] Reason for changing the channel's bitrate
|
||||||
|
* @returns {Promise<StageChannel>}
|
||||||
|
* @example
|
||||||
|
* // Set the bitrate of a voice channel
|
||||||
|
* stageChannel.setBitrate(48_000)
|
||||||
|
* .then(channel => console.log(`Set bitrate to ${channel.bitrate}bps for ${channel.name}`))
|
||||||
|
* .catch(console.error);
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the RTC region of the channel.
|
* Sets the RTC region of the channel.
|
||||||
* @method setRTCRegion
|
* @method setRTCRegion
|
||||||
@@ -69,4 +84,29 @@ class StageChannel extends BaseGuildVoiceChannel {
|
|||||||
* stageChannel.setRTCRegion(null, 'We want to let Discord decide.');
|
* stageChannel.setRTCRegion(null, 'We want to let Discord decide.');
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the user limit of the channel.
|
||||||
|
* @method setUserLimit
|
||||||
|
* @memberof StageChannel
|
||||||
|
* @instance
|
||||||
|
* @param {number} userLimit The new user limit
|
||||||
|
* @param {string} [reason] Reason for changing the user limit
|
||||||
|
* @returns {Promise<StageChannel>}
|
||||||
|
* @example
|
||||||
|
* // Set the user limit of a voice channel
|
||||||
|
* stageChannel.setUserLimit(42)
|
||||||
|
* .then(channel => console.log(`Set user limit to ${channel.userLimit} for ${channel.name}`))
|
||||||
|
* .catch(console.error);
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the camera video quality mode of the channel.
|
||||||
|
* @method setVideoQualityMode
|
||||||
|
* @memberof StageChannel
|
||||||
|
* @instance
|
||||||
|
* @param {VideoQualityMode} videoQualityMode The new camera video quality mode.
|
||||||
|
* @param {string} [reason] Reason for changing the camera video quality mode.
|
||||||
|
* @returns {Promise<StageChannel>}
|
||||||
|
*/
|
||||||
|
|
||||||
module.exports = StageChannel;
|
module.exports = StageChannel;
|
||||||
|
|||||||
@@ -2,71 +2,12 @@
|
|||||||
|
|
||||||
const { PermissionFlagsBits } = require('discord-api-types/v10');
|
const { PermissionFlagsBits } = require('discord-api-types/v10');
|
||||||
const BaseGuildVoiceChannel = require('./BaseGuildVoiceChannel');
|
const BaseGuildVoiceChannel = require('./BaseGuildVoiceChannel');
|
||||||
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
|
||||||
const MessageManager = require('../managers/MessageManager');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a guild voice channel on Discord.
|
* Represents a guild voice channel on Discord.
|
||||||
* @extends {BaseGuildVoiceChannel}
|
* @extends {BaseGuildVoiceChannel}
|
||||||
* @implements {TextBasedChannel}
|
|
||||||
*/
|
*/
|
||||||
class VoiceChannel extends BaseGuildVoiceChannel {
|
class VoiceChannel extends BaseGuildVoiceChannel {
|
||||||
constructor(guild, data, client) {
|
|
||||||
super(guild, data, client, false);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A manager of the messages sent to this channel
|
|
||||||
* @type {MessageManager}
|
|
||||||
*/
|
|
||||||
this.messages = new MessageManager(this);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If the guild considers this channel NSFW
|
|
||||||
* @type {boolean}
|
|
||||||
*/
|
|
||||||
this.nsfw = Boolean(data.nsfw);
|
|
||||||
|
|
||||||
this._patch(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
_patch(data) {
|
|
||||||
super._patch(data);
|
|
||||||
|
|
||||||
if ('video_quality_mode' in data) {
|
|
||||||
/**
|
|
||||||
* The camera video quality mode of the channel.
|
|
||||||
* @type {?VideoQualityMode}
|
|
||||||
*/
|
|
||||||
this.videoQualityMode = data.video_quality_mode;
|
|
||||||
} else {
|
|
||||||
this.videoQualityMode ??= null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('last_message_id' in data) {
|
|
||||||
/**
|
|
||||||
* The last message id sent in the channel, if one was sent
|
|
||||||
* @type {?Snowflake}
|
|
||||||
*/
|
|
||||||
this.lastMessageId = data.last_message_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('messages' in data) {
|
|
||||||
for (const message of data.messages) this.messages._add(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('rate_limit_per_user' in data) {
|
|
||||||
/**
|
|
||||||
* The rate limit per user (slowmode) for this channel in seconds
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
this.rateLimitPerUser = data.rate_limit_per_user;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('nsfw' in data) {
|
|
||||||
this.nsfw = Boolean(data.nsfw);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the channel is joinable by the client user
|
* Whether the channel is joinable by the client user
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
@@ -94,64 +35,22 @@ class VoiceChannel extends BaseGuildVoiceChannel {
|
|||||||
permissions.has(PermissionFlagsBits.Speak, false)
|
permissions.has(PermissionFlagsBits.Speak, false)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the bitrate of the channel.
|
|
||||||
* @param {number} bitrate The new bitrate
|
|
||||||
* @param {string} [reason] Reason for changing the channel's bitrate
|
|
||||||
* @returns {Promise<VoiceChannel>}
|
|
||||||
* @example
|
|
||||||
* // Set the bitrate of a voice channel
|
|
||||||
* voiceChannel.setBitrate(48_000)
|
|
||||||
* .then(vc => console.log(`Set bitrate to ${vc.bitrate}bps for ${vc.name}`))
|
|
||||||
* .catch(console.error);
|
|
||||||
*/
|
|
||||||
setBitrate(bitrate, reason) {
|
|
||||||
return this.edit({ bitrate, reason });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the user limit of the channel.
|
|
||||||
* @param {number} userLimit The new user limit
|
|
||||||
* @param {string} [reason] Reason for changing the user limit
|
|
||||||
* @returns {Promise<VoiceChannel>}
|
|
||||||
* @example
|
|
||||||
* // Set the user limit of a voice channel
|
|
||||||
* voiceChannel.setUserLimit(42)
|
|
||||||
* .then(vc => console.log(`Set user limit to ${vc.userLimit} for ${vc.name}`))
|
|
||||||
* .catch(console.error);
|
|
||||||
*/
|
|
||||||
setUserLimit(userLimit, reason) {
|
|
||||||
return this.edit({ userLimit, reason });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the camera video quality mode of the channel.
|
|
||||||
* @param {VideoQualityMode} videoQualityMode The new camera video quality mode.
|
|
||||||
* @param {string} [reason] Reason for changing the camera video quality mode.
|
|
||||||
* @returns {Promise<VoiceChannel>}
|
|
||||||
*/
|
|
||||||
setVideoQualityMode(videoQualityMode, reason) {
|
|
||||||
return this.edit({ videoQualityMode, reason });
|
|
||||||
}
|
|
||||||
|
|
||||||
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
|
||||||
/* eslint-disable no-empty-function */
|
|
||||||
get lastMessage() {}
|
|
||||||
send() {}
|
|
||||||
sendTyping() {}
|
|
||||||
createMessageCollector() {}
|
|
||||||
awaitMessages() {}
|
|
||||||
createMessageComponentCollector() {}
|
|
||||||
awaitMessageComponent() {}
|
|
||||||
bulkDelete() {}
|
|
||||||
fetchWebhooks() {}
|
|
||||||
createWebhook() {}
|
|
||||||
setRateLimitPerUser() {}
|
|
||||||
setNSFW() {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextBasedChannel.applyToClass(VoiceChannel, true, ['lastPinAt']);
|
/**
|
||||||
|
* Sets the bitrate of the channel.
|
||||||
|
* @method setBitrate
|
||||||
|
* @memberof VoiceChannel
|
||||||
|
* @instance
|
||||||
|
* @param {number} bitrate The new bitrate
|
||||||
|
* @param {string} [reason] Reason for changing the channel's bitrate
|
||||||
|
* @returns {Promise<VoiceChannel>}
|
||||||
|
* @example
|
||||||
|
* // Set the bitrate of a voice channel
|
||||||
|
* voiceChannel.setBitrate(48_000)
|
||||||
|
* .then(channel => console.log(`Set bitrate to ${channel.bitrate}bps for ${channel.name}`))
|
||||||
|
* .catch(console.error);
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the RTC region of the channel.
|
* Sets the RTC region of the channel.
|
||||||
@@ -169,4 +68,29 @@ TextBasedChannel.applyToClass(VoiceChannel, true, ['lastPinAt']);
|
|||||||
* voiceChannel.setRTCRegion(null, 'We want to let Discord decide.');
|
* voiceChannel.setRTCRegion(null, 'We want to let Discord decide.');
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the user limit of the channel.
|
||||||
|
* @method setUserLimit
|
||||||
|
* @memberof VoiceChannel
|
||||||
|
* @instance
|
||||||
|
* @param {number} userLimit The new user limit
|
||||||
|
* @param {string} [reason] Reason for changing the user limit
|
||||||
|
* @returns {Promise<VoiceChannel>}
|
||||||
|
* @example
|
||||||
|
* // Set the user limit of a voice channel
|
||||||
|
* voiceChannel.setUserLimit(42)
|
||||||
|
* .then(channel => console.log(`Set user limit to ${channel.userLimit} for ${channel.name}`))
|
||||||
|
* .catch(console.error);
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the camera video quality mode of the channel.
|
||||||
|
* @method setVideoQualityMode
|
||||||
|
* @memberof VoiceChannel
|
||||||
|
* @instance
|
||||||
|
* @param {VideoQualityMode} videoQualityMode The new camera video quality mode.
|
||||||
|
* @param {string} [reason] Reason for changing the camera video quality mode.
|
||||||
|
* @returns {Promise<VoiceChannel>}
|
||||||
|
*/
|
||||||
|
|
||||||
module.exports = VoiceChannel;
|
module.exports = VoiceChannel;
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ class Webhook {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The channel the webhook belongs to
|
* The channel the webhook belongs to
|
||||||
* @type {?(TextChannel|VoiceChannel|NewsChannel|ForumChannel)}
|
* @type {?(TextChannel|VoiceChannel|StageChannel|NewsChannel|ForumChannel)}
|
||||||
* @readonly
|
* @readonly
|
||||||
*/
|
*/
|
||||||
get channel() {
|
get channel() {
|
||||||
|
|||||||
@@ -346,7 +346,7 @@ class TextBasedChannel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options used to create a {@link Webhook} in a {@link TextChannel} or a {@link NewsChannel}.
|
* Options used to create a {@link Webhook}.
|
||||||
* @typedef {Object} ChannelWebhookCreateOptions
|
* @typedef {Object} ChannelWebhookCreateOptions
|
||||||
* @property {string} name The name of the webhook
|
* @property {string} name The name of the webhook
|
||||||
* @property {?(BufferResolvable|Base64Resolvable)} [avatar] Avatar for the webhook
|
* @property {?(BufferResolvable|Base64Resolvable)} [avatar] Avatar for the webhook
|
||||||
|
|||||||
@@ -66,7 +66,8 @@ exports.NonSystemMessageTypes = [
|
|||||||
* * NewsChannel
|
* * NewsChannel
|
||||||
* * ThreadChannel
|
* * ThreadChannel
|
||||||
* * VoiceChannel
|
* * VoiceChannel
|
||||||
* @typedef {TextChannel|NewsChannel|ThreadChannel|VoiceChannel} GuildTextBasedChannel
|
* * StageChannel
|
||||||
|
* @typedef {TextChannel|NewsChannel|ThreadChannel|VoiceChannel|StageChannel} GuildTextBasedChannel
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
39
packages/discord.js/typings/index.d.ts
vendored
39
packages/discord.js/typings/index.d.ts
vendored
@@ -633,17 +633,26 @@ export class BaseGuildTextChannel extends TextBasedChannelMixin(GuildChannel, tr
|
|||||||
public setType(type: ChannelType.GuildAnnouncement, reason?: string): Promise<NewsChannel>;
|
public setType(type: ChannelType.GuildAnnouncement, reason?: string): Promise<NewsChannel>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class BaseGuildVoiceChannel extends GuildChannel {
|
export class BaseGuildVoiceChannel extends TextBasedChannelMixin(GuildChannel, true, [
|
||||||
|
'lastPinTimestamp',
|
||||||
|
'lastPinAt',
|
||||||
|
]) {
|
||||||
public constructor(guild: Guild, data?: RawGuildChannelData);
|
public constructor(guild: Guild, data?: RawGuildChannelData);
|
||||||
public get members(): Collection<Snowflake, GuildMember>;
|
public bitrate: number;
|
||||||
public get full(): boolean;
|
public get full(): boolean;
|
||||||
public get joinable(): boolean;
|
public get joinable(): boolean;
|
||||||
|
public get members(): Collection<Snowflake, GuildMember>;
|
||||||
|
public nsfw: boolean;
|
||||||
|
public rateLimitPerUser: number | null;
|
||||||
public rtcRegion: string | null;
|
public rtcRegion: string | null;
|
||||||
public bitrate: number;
|
|
||||||
public userLimit: number;
|
public userLimit: number;
|
||||||
|
public videoQualityMode: VideoQualityMode | null;
|
||||||
public createInvite(options?: InviteCreateOptions): Promise<Invite>;
|
public createInvite(options?: InviteCreateOptions): Promise<Invite>;
|
||||||
public setRTCRegion(rtcRegion: string | null, reason?: string): Promise<this>;
|
|
||||||
public fetchInvites(cache?: boolean): Promise<Collection<string, Invite>>;
|
public fetchInvites(cache?: boolean): Promise<Collection<string, Invite>>;
|
||||||
|
public setBitrate(bitrate: number, reason?: string): Promise<this>;
|
||||||
|
public setRTCRegion(rtcRegion: string | null, reason?: string): Promise<this>;
|
||||||
|
public setUserLimit(userLimit: number, reason?: string): Promise<this>;
|
||||||
|
public setVideoQualityMode(videoQualityMode: VideoQualityMode, reason?: string): Promise<this>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type EnumLike<E, V> = Record<keyof E, V>;
|
export type EnumLike<E, V> = Record<keyof E, V>;
|
||||||
@@ -2726,9 +2735,9 @@ export {
|
|||||||
} from '@sapphire/snowflake';
|
} from '@sapphire/snowflake';
|
||||||
|
|
||||||
export class StageChannel extends BaseGuildVoiceChannel {
|
export class StageChannel extends BaseGuildVoiceChannel {
|
||||||
|
public get stageInstance(): StageInstance | null;
|
||||||
public topic: string | null;
|
public topic: string | null;
|
||||||
public type: ChannelType.GuildStageVoice;
|
public type: ChannelType.GuildStageVoice;
|
||||||
public get stageInstance(): StageInstance | null;
|
|
||||||
public createStageInstance(options: StageInstanceCreateOptions): Promise<StageInstance>;
|
public createStageInstance(options: StageInstanceCreateOptions): Promise<StageInstance>;
|
||||||
public setTopic(topic: string): Promise<StageChannel>;
|
public setTopic(topic: string): Promise<StageChannel>;
|
||||||
}
|
}
|
||||||
@@ -3179,18 +3188,9 @@ export type ComponentData =
|
|||||||
| ModalActionRowComponentData
|
| ModalActionRowComponentData
|
||||||
| ActionRowData<MessageActionRowComponentData | ModalActionRowComponentData>;
|
| ActionRowData<MessageActionRowComponentData | ModalActionRowComponentData>;
|
||||||
|
|
||||||
export class VoiceChannel extends TextBasedChannelMixin(BaseGuildVoiceChannel, true, [
|
export class VoiceChannel extends BaseGuildVoiceChannel {
|
||||||
'lastPinTimestamp',
|
|
||||||
'lastPinAt',
|
|
||||||
]) {
|
|
||||||
public videoQualityMode: VideoQualityMode | null;
|
|
||||||
public get speakable(): boolean;
|
public get speakable(): boolean;
|
||||||
public type: ChannelType.GuildVoice;
|
public type: ChannelType.GuildVoice;
|
||||||
public nsfw: boolean;
|
|
||||||
public rateLimitPerUser: number | null;
|
|
||||||
public setBitrate(bitrate: number, reason?: string): Promise<VoiceChannel>;
|
|
||||||
public setUserLimit(userLimit: number, reason?: string): Promise<VoiceChannel>;
|
|
||||||
public setVideoQualityMode(videoQualityMode: VideoQualityMode, reason?: string): Promise<VoiceChannel>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class VoiceRegion {
|
export class VoiceRegion {
|
||||||
@@ -3245,7 +3245,7 @@ export class Webhook extends WebhookMixin() {
|
|||||||
public token: string | null;
|
public token: string | null;
|
||||||
public type: WebhookType;
|
public type: WebhookType;
|
||||||
public applicationId: Snowflake | null;
|
public applicationId: Snowflake | null;
|
||||||
public get channel(): TextChannel | VoiceChannel | NewsChannel | ForumChannel | null;
|
public get channel(): TextChannel | VoiceChannel | NewsChannel | ForumChannel | StageChannel | null;
|
||||||
public isUserCreated(): this is this & {
|
public isUserCreated(): this is this & {
|
||||||
type: WebhookType.Incoming;
|
type: WebhookType.Incoming;
|
||||||
applicationId: null;
|
applicationId: null;
|
||||||
@@ -4721,7 +4721,7 @@ export interface ChannelWebhookCreateOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface WebhookCreateOptions extends ChannelWebhookCreateOptions {
|
export interface WebhookCreateOptions extends ChannelWebhookCreateOptions {
|
||||||
channel: TextChannel | NewsChannel | VoiceChannel | ForumChannel | Snowflake;
|
channel: TextChannel | NewsChannel | VoiceChannel | StageChannel | ForumChannel | Snowflake;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ClientEvents {
|
export interface ClientEvents {
|
||||||
@@ -6196,8 +6196,7 @@ export type Channel =
|
|||||||
|
|
||||||
export type TextBasedChannel = Exclude<
|
export type TextBasedChannel = Exclude<
|
||||||
Extract<Channel, { type: TextChannelType }>,
|
Extract<Channel, { type: TextChannelType }>,
|
||||||
// TODO: Remove stage channel upon implementation of text-in-stage.
|
PartialGroupDMChannel | ForumChannel
|
||||||
PartialGroupDMChannel | ForumChannel | StageChannel
|
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export type TextBasedChannelTypes = TextBasedChannel['type'];
|
export type TextBasedChannelTypes = TextBasedChannel['type'];
|
||||||
@@ -6279,7 +6278,7 @@ export type WebhookClientOptions = Pick<ClientOptions, 'allowedMentions' | 'rest
|
|||||||
export interface WebhookEditOptions {
|
export interface WebhookEditOptions {
|
||||||
name?: string;
|
name?: string;
|
||||||
avatar?: BufferResolvable | null;
|
avatar?: BufferResolvable | null;
|
||||||
channel?: GuildTextChannelResolvable;
|
channel?: GuildTextChannelResolvable | VoiceChannel | ForumChannel | StageChannel;
|
||||||
reason?: string;
|
reason?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1979,7 +1979,12 @@ declare const GuildTextBasedChannel: GuildTextBasedChannel;
|
|||||||
|
|
||||||
expectType<TextBasedChannel>(TextBasedChannel);
|
expectType<TextBasedChannel>(TextBasedChannel);
|
||||||
expectType<
|
expectType<
|
||||||
ChannelType.GuildText | ChannelType.DM | ChannelType.GuildAnnouncement | ChannelType.GuildVoice | ThreadChannelType
|
| ChannelType.GuildText
|
||||||
|
| ChannelType.DM
|
||||||
|
| ChannelType.GuildAnnouncement
|
||||||
|
| ChannelType.GuildVoice
|
||||||
|
| ChannelType.GuildStageVoice
|
||||||
|
| ThreadChannelType
|
||||||
>(TextBasedChannelTypes);
|
>(TextBasedChannelTypes);
|
||||||
expectType<StageChannel | VoiceChannel>(VoiceBasedChannel);
|
expectType<StageChannel | VoiceChannel>(VoiceBasedChannel);
|
||||||
expectType<GuildBasedChannel>(GuildBasedChannel);
|
expectType<GuildBasedChannel>(GuildBasedChannel);
|
||||||
|
|||||||
Reference in New Issue
Block a user