mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 20:43:30 +01:00
feat(vcs): add missing property and methods (#8002)
This commit is contained in:
@@ -89,16 +89,6 @@ class BaseGuildTextChannel extends GuildChannel {
|
|||||||
return this.edit({ defaultAutoArchiveDuration }, reason);
|
return this.edit({ defaultAutoArchiveDuration }, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets whether this channel is flagged as NSFW.
|
|
||||||
* @param {boolean} [nsfw=true] Whether the channel should be considered NSFW
|
|
||||||
* @param {string} [reason] Reason for changing the channel's NSFW flag
|
|
||||||
* @returns {Promise<TextChannel>}
|
|
||||||
*/
|
|
||||||
setNSFW(nsfw = true, reason) {
|
|
||||||
return this.edit({ nsfw }, reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the type of this channel (only conversion between text and news is supported)
|
* Sets the type of this channel (only conversion between text and news is supported)
|
||||||
* @param {string} type The new channel type
|
* @param {string} type The new channel type
|
||||||
@@ -186,6 +176,8 @@ class BaseGuildTextChannel extends GuildChannel {
|
|||||||
bulkDelete() {}
|
bulkDelete() {}
|
||||||
fetchWebhooks() {}
|
fetchWebhooks() {}
|
||||||
createWebhook() {}
|
createWebhook() {}
|
||||||
|
setRateLimitPerUser() {}
|
||||||
|
setNSFW() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextBasedChannel.applyToClass(BaseGuildTextChannel, true);
|
TextBasedChannel.applyToClass(BaseGuildTextChannel, true);
|
||||||
|
|||||||
@@ -114,8 +114,16 @@ class DMChannel extends Channel {
|
|||||||
// Doesn't work on DM channels; bulkDelete() {}
|
// Doesn't work on DM channels; bulkDelete() {}
|
||||||
// Doesn't work on DM channels; fetchWebhooks() {}
|
// Doesn't work on DM channels; fetchWebhooks() {}
|
||||||
// Doesn't work on DM channels; createWebhook() {}
|
// Doesn't work on DM channels; createWebhook() {}
|
||||||
|
// Doesn't work on DM channels; setRateLimitPerUser() {}
|
||||||
|
// Doesn't work on DM channels; setNSFW() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextBasedChannel.applyToClass(DMChannel, true, ['bulkDelete', 'fetchWebhooks', 'createWebhook']);
|
TextBasedChannel.applyToClass(DMChannel, true, [
|
||||||
|
'bulkDelete',
|
||||||
|
'fetchWebhooks',
|
||||||
|
'createWebhook',
|
||||||
|
'setRateLimitPerUser',
|
||||||
|
'setNSFW',
|
||||||
|
]);
|
||||||
|
|
||||||
module.exports = DMChannel;
|
module.exports = DMChannel;
|
||||||
|
|||||||
@@ -537,8 +537,10 @@ class ThreadChannel extends Channel {
|
|||||||
createMessageComponentCollector() {}
|
createMessageComponentCollector() {}
|
||||||
awaitMessageComponent() {}
|
awaitMessageComponent() {}
|
||||||
bulkDelete() {}
|
bulkDelete() {}
|
||||||
|
// Doesn't work on Thread channels; setRateLimitPerUser() {}
|
||||||
|
// Doesn't work on Thread channels; setNSFW() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextBasedChannel.applyToClass(ThreadChannel, true);
|
TextBasedChannel.applyToClass(ThreadChannel, true, ['setRateLimitPerUser', 'setNSFW']);
|
||||||
|
|
||||||
module.exports = ThreadChannel;
|
module.exports = ThreadChannel;
|
||||||
|
|||||||
@@ -47,6 +47,14 @@ class VoiceChannel extends BaseGuildVoiceChannel {
|
|||||||
if ('messages' in data) {
|
if ('messages' in data) {
|
||||||
for (const message of data.messages) this.messages._add(message);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -129,6 +137,8 @@ class VoiceChannel extends BaseGuildVoiceChannel {
|
|||||||
bulkDelete() {}
|
bulkDelete() {}
|
||||||
fetchWebhooks() {}
|
fetchWebhooks() {}
|
||||||
createWebhook() {}
|
createWebhook() {}
|
||||||
|
setRateLimitPerUser() {}
|
||||||
|
setNSFW() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the RTC region of the channel.
|
* Sets the RTC region of the channel.
|
||||||
|
|||||||
@@ -367,6 +367,26 @@ class TextBasedChannel {
|
|||||||
return this.guild.channels.createWebhook(this.id, name, options);
|
return this.guild.channels.createWebhook(this.id, name, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the rate limit per user (slowmode) for this channel.
|
||||||
|
* @param {number} rateLimitPerUser The new rate limit in seconds
|
||||||
|
* @param {string} [reason] Reason for changing the channel's rate limit
|
||||||
|
* @returns {Promise<this>}
|
||||||
|
*/
|
||||||
|
setRateLimitPerUser(rateLimitPerUser, reason) {
|
||||||
|
return this.edit({ rateLimitPerUser }, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether this channel is flagged as NSFW.
|
||||||
|
* @param {boolean} [nsfw=true] Whether the channel should be considered NSFW
|
||||||
|
* @param {string} [reason] Reason for changing the channel's NSFW flag
|
||||||
|
* @returns {Promise<this>}
|
||||||
|
*/
|
||||||
|
setNSFW(nsfw = true, reason) {
|
||||||
|
return this.edit({ nsfw }, reason);
|
||||||
|
}
|
||||||
|
|
||||||
static applyToClass(structure, full = false, ignore = []) {
|
static applyToClass(structure, full = false, ignore = []) {
|
||||||
const props = ['send'];
|
const props = ['send'];
|
||||||
if (full) {
|
if (full) {
|
||||||
@@ -381,6 +401,8 @@ class TextBasedChannel {
|
|||||||
'awaitMessageComponent',
|
'awaitMessageComponent',
|
||||||
'fetchWebhooks',
|
'fetchWebhooks',
|
||||||
'createWebhook',
|
'createWebhook',
|
||||||
|
'setRateLimitPerUser',
|
||||||
|
'setNSFW',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
for (const prop of props) {
|
for (const prop of props) {
|
||||||
|
|||||||
17
packages/discord.js/typings/index.d.ts
vendored
17
packages/discord.js/typings/index.d.ts
vendored
@@ -514,6 +514,7 @@ export class BaseGuildEmoji extends Emoji {
|
|||||||
export class BaseGuildTextChannel extends TextBasedChannelMixin(GuildChannel) {
|
export class BaseGuildTextChannel extends TextBasedChannelMixin(GuildChannel) {
|
||||||
protected constructor(guild: Guild, data?: RawGuildChannelData, client?: Client, immediatePatch?: boolean);
|
protected constructor(guild: Guild, data?: RawGuildChannelData, client?: Client, immediatePatch?: boolean);
|
||||||
public defaultAutoArchiveDuration?: ThreadAutoArchiveDuration;
|
public defaultAutoArchiveDuration?: ThreadAutoArchiveDuration;
|
||||||
|
public rateLimitPerUser: number | null;
|
||||||
public nsfw: boolean;
|
public nsfw: boolean;
|
||||||
public threads: ThreadManager<AllowedThreadTypeForTextChannel | AllowedThreadTypeForNewsChannel>;
|
public threads: ThreadManager<AllowedThreadTypeForTextChannel | AllowedThreadTypeForNewsChannel>;
|
||||||
public topic: string | null;
|
public topic: string | null;
|
||||||
@@ -523,7 +524,6 @@ export class BaseGuildTextChannel extends TextBasedChannelMixin(GuildChannel) {
|
|||||||
defaultAutoArchiveDuration: ThreadAutoArchiveDuration,
|
defaultAutoArchiveDuration: ThreadAutoArchiveDuration,
|
||||||
reason?: string,
|
reason?: string,
|
||||||
): Promise<this>;
|
): Promise<this>;
|
||||||
public setNSFW(nsfw?: boolean, reason?: string): Promise<this>;
|
|
||||||
public setTopic(topic: string | null, reason?: string): Promise<this>;
|
public setTopic(topic: string | null, reason?: string): Promise<this>;
|
||||||
public setType(type: Pick<typeof ChannelType, 'GuildText'>, reason?: string): Promise<TextChannel>;
|
public setType(type: Pick<typeof ChannelType, 'GuildText'>, reason?: string): Promise<TextChannel>;
|
||||||
public setType(type: Pick<typeof ChannelType, 'GuildNews'>, reason?: string): Promise<NewsChannel>;
|
public setType(type: Pick<typeof ChannelType, 'GuildNews'>, reason?: string): Promise<NewsChannel>;
|
||||||
@@ -1036,7 +1036,13 @@ export class DataResolver extends null {
|
|||||||
public static resolveGuildTemplateCode(data: GuildTemplateResolvable): string;
|
public static resolveGuildTemplateCode(data: GuildTemplateResolvable): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DMChannel extends TextBasedChannelMixin(Channel, ['bulkDelete', 'fetchWebhooks', 'createWebhook']) {
|
export class DMChannel extends TextBasedChannelMixin(Channel, [
|
||||||
|
'bulkDelete',
|
||||||
|
'fetchWebhooks',
|
||||||
|
'createWebhook',
|
||||||
|
'setRateLimitPerUser',
|
||||||
|
'setNSFW',
|
||||||
|
]) {
|
||||||
private constructor(client: Client, data?: RawDMChannelData);
|
private constructor(client: Client, data?: RawDMChannelData);
|
||||||
public recipientId: Snowflake;
|
public recipientId: Snowflake;
|
||||||
public get recipient(): User | null;
|
public get recipient(): User | null;
|
||||||
@@ -2449,7 +2455,6 @@ export class TextChannel extends BaseGuildTextChannel {
|
|||||||
public rateLimitPerUser: number;
|
public rateLimitPerUser: number;
|
||||||
public threads: ThreadManager<AllowedThreadTypeForTextChannel>;
|
public threads: ThreadManager<AllowedThreadTypeForTextChannel>;
|
||||||
public type: ChannelType.GuildText;
|
public type: ChannelType.GuildText;
|
||||||
public setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise<TextChannel>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AnyThreadChannel = PublicThreadChannel | PrivateThreadChannel;
|
export type AnyThreadChannel = PublicThreadChannel | PrivateThreadChannel;
|
||||||
@@ -2464,7 +2469,7 @@ export interface PrivateThreadChannel extends ThreadChannel {
|
|||||||
type: ChannelType.GuildPrivateThread;
|
type: ChannelType.GuildPrivateThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ThreadChannel extends TextBasedChannelMixin(Channel, ['fetchWebhooks', 'createWebhook']) {
|
export class ThreadChannel extends TextBasedChannelMixin(Channel, ['fetchWebhooks', 'createWebhook', 'setNSFW']) {
|
||||||
private constructor(guild: Guild, data?: RawThreadChannelData, client?: Client, fromInteraction?: boolean);
|
private constructor(guild: Guild, data?: RawThreadChannelData, client?: Client, fromInteraction?: boolean);
|
||||||
public archived: boolean | null;
|
public archived: boolean | null;
|
||||||
public get archivedAt(): Date | null;
|
public get archivedAt(): Date | null;
|
||||||
@@ -2513,7 +2518,6 @@ export class ThreadChannel extends TextBasedChannelMixin(Channel, ['fetchWebhook
|
|||||||
public setInvitable(invitable?: boolean, reason?: string): Promise<AnyThreadChannel>;
|
public setInvitable(invitable?: boolean, reason?: string): Promise<AnyThreadChannel>;
|
||||||
public setLocked(locked?: boolean, reason?: string): Promise<AnyThreadChannel>;
|
public setLocked(locked?: boolean, reason?: string): Promise<AnyThreadChannel>;
|
||||||
public setName(name: string, reason?: string): Promise<AnyThreadChannel>;
|
public setName(name: string, reason?: string): Promise<AnyThreadChannel>;
|
||||||
public setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise<AnyThreadChannel>;
|
|
||||||
public toString(): ChannelMention;
|
public toString(): ChannelMention;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2696,6 +2700,7 @@ export class VoiceChannel extends TextBasedChannelMixin(BaseGuildVoiceChannel, [
|
|||||||
public videoQualityMode: VideoQualityMode | null;
|
public videoQualityMode: VideoQualityMode | null;
|
||||||
public get speakable(): boolean;
|
public get speakable(): boolean;
|
||||||
public type: ChannelType.GuildVoice;
|
public type: ChannelType.GuildVoice;
|
||||||
|
public rateLimitPerUser: number | null;
|
||||||
public setBitrate(bitrate: number, reason?: string): Promise<VoiceChannel>;
|
public setBitrate(bitrate: number, reason?: string): Promise<VoiceChannel>;
|
||||||
public setUserLimit(userLimit: number, reason?: string): Promise<VoiceChannel>;
|
public setUserLimit(userLimit: number, reason?: string): Promise<VoiceChannel>;
|
||||||
public setVideoQualityMode(videoQualityMode: VideoQualityMode, reason?: string): Promise<VoiceChannel>;
|
public setVideoQualityMode(videoQualityMode: VideoQualityMode, reason?: string): Promise<VoiceChannel>;
|
||||||
@@ -3465,6 +3470,8 @@ export interface TextBasedChannelFields extends PartialTextBasedChannelFields {
|
|||||||
createWebhook(name: string, options?: ChannelWebhookCreateOptions): Promise<Webhook>;
|
createWebhook(name: string, options?: ChannelWebhookCreateOptions): Promise<Webhook>;
|
||||||
fetchWebhooks(): Promise<Collection<Snowflake, Webhook>>;
|
fetchWebhooks(): Promise<Collection<Snowflake, Webhook>>;
|
||||||
sendTyping(): Promise<void>;
|
sendTyping(): Promise<void>;
|
||||||
|
setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise<this>;
|
||||||
|
setNSFW(nsfw?: boolean, reason?: string): Promise<this>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function PartialWebhookMixin<T>(Base?: Constructable<T>): Constructable<T & PartialWebhookFields>;
|
export function PartialWebhookMixin<T>(Base?: Constructable<T>): Constructable<T & PartialWebhookFields>;
|
||||||
|
|||||||
Reference in New Issue
Block a user