mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 11:03:30 +01:00
refactor(Channel): change channel types to UPPER_CASE (#6035)
This commit is contained in:
@@ -12,7 +12,7 @@ class ChannelUpdateAction extends Action {
|
|||||||
if (channel) {
|
if (channel) {
|
||||||
const old = channel._update(data);
|
const old = channel._update(data);
|
||||||
|
|
||||||
if (ChannelTypes[channel.type.toUpperCase()] !== data.type) {
|
if (ChannelTypes[channel.type] !== data.type) {
|
||||||
const newChannel = Channel.create(this.client, data, channel.guild);
|
const newChannel = Channel.create(this.client, data, channel.guild);
|
||||||
for (const [id, message] of channel.messages.cache) newChannel.messages.cache.set(id, message);
|
for (const [id, message] of channel.messages.cache) newChannel.messages.cache.set(id, message);
|
||||||
newChannel._typing = new Map(channel._typing);
|
newChannel._typing = new Map(channel._typing);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const Action = require('./Action');
|
const Action = require('./Action');
|
||||||
const { Events } = require('../../util/Constants');
|
const { Events, TextBasedChannelTypes } = require('../../util/Constants');
|
||||||
|
|
||||||
class GuildDeleteAction extends Action {
|
class GuildDeleteAction extends Action {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -15,7 +15,7 @@ class GuildDeleteAction extends Action {
|
|||||||
let guild = client.guilds.cache.get(data.id);
|
let guild = client.guilds.cache.get(data.id);
|
||||||
if (guild) {
|
if (guild) {
|
||||||
for (const channel of guild.channels.cache.values()) {
|
for (const channel of guild.channels.cache.values()) {
|
||||||
if (channel.type === 'text') channel.stopTyping(true);
|
if (channel.type in TextBasedChannelTypes) channel.stopTyping(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.unavailable) {
|
if (data.unavailable) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const Action = require('./Action');
|
const Action = require('./Action');
|
||||||
const { Events } = require('../../util/Constants');
|
const { Events, VoiceBasedChannelTypes } = require('../../util/Constants');
|
||||||
const { PartialTypes } = require('../../util/Constants');
|
const { PartialTypes } = require('../../util/Constants');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -23,7 +23,7 @@ class MessageReactionAdd extends Action {
|
|||||||
|
|
||||||
// Verify channel
|
// Verify channel
|
||||||
const channel = this.getChannel(data);
|
const channel = this.getChannel(data);
|
||||||
if (!channel || channel.type === 'voice') return false;
|
if (!channel || channel.type in VoiceBasedChannelTypes) return false;
|
||||||
|
|
||||||
// Verify message
|
// Verify message
|
||||||
const message = this.getMessage(data, channel);
|
const message = this.getMessage(data, channel);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const Action = require('./Action');
|
const Action = require('./Action');
|
||||||
const { Events } = require('../../util/Constants');
|
const { Events, VoiceBasedChannelTypes } = require('../../util/Constants');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
{ user_id: 'id',
|
{ user_id: 'id',
|
||||||
@@ -20,7 +20,7 @@ class MessageReactionRemove extends Action {
|
|||||||
|
|
||||||
// Verify channel
|
// Verify channel
|
||||||
const channel = this.getChannel(data);
|
const channel = this.getChannel(data);
|
||||||
if (!channel || channel.type === 'voice') return false;
|
if (!channel || channel.type in VoiceBasedChannelTypes) return false;
|
||||||
|
|
||||||
// Verify message
|
// Verify message
|
||||||
const message = this.getMessage(data, channel);
|
const message = this.getMessage(data, channel);
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const Action = require('./Action');
|
const Action = require('./Action');
|
||||||
const { Events } = require('../../util/Constants');
|
const { Events, VoiceBasedChannelTypes } = require('../../util/Constants');
|
||||||
|
|
||||||
class MessageReactionRemoveAll extends Action {
|
class MessageReactionRemoveAll extends Action {
|
||||||
handle(data) {
|
handle(data) {
|
||||||
// Verify channel
|
// Verify channel
|
||||||
const channel = this.getChannel(data);
|
const channel = this.getChannel(data);
|
||||||
if (!channel || channel.type === 'voice') return false;
|
if (!channel || channel.type in VoiceBasedChannelTypes) return false;
|
||||||
|
|
||||||
// Verify message
|
// Verify message
|
||||||
const message = this.getMessage(data, channel);
|
const message = this.getMessage(data, channel);
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const Action = require('./Action');
|
const Action = require('./Action');
|
||||||
const { Events } = require('../../util/Constants');
|
const { Events, VoiceBasedChannelTypes } = require('../../util/Constants');
|
||||||
|
|
||||||
class MessageReactionRemoveEmoji extends Action {
|
class MessageReactionRemoveEmoji extends Action {
|
||||||
handle(data) {
|
handle(data) {
|
||||||
const channel = this.getChannel(data);
|
const channel = this.getChannel(data);
|
||||||
if (!channel || channel.type === 'voice') return false;
|
if (!channel || channel.type in VoiceBasedChannelTypes) return false;
|
||||||
|
|
||||||
const message = this.getMessage(data, channel);
|
const message = this.getMessage(data, channel);
|
||||||
if (!message) return false;
|
if (!message) return false;
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const Action = require('./Action');
|
const Action = require('./Action');
|
||||||
const { Events } = require('../../util/Constants');
|
const { Events, TextBasedChannelTypes } = require('../../util/Constants');
|
||||||
const textBasedChannelTypes = ['dm', 'text', 'news', 'news_thread', 'public_thread', 'private_thread'];
|
|
||||||
|
|
||||||
class TypingStart extends Action {
|
class TypingStart extends Action {
|
||||||
handle(data) {
|
handle(data) {
|
||||||
@@ -10,7 +9,7 @@ class TypingStart extends Action {
|
|||||||
if (!channel) {
|
if (!channel) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!textBasedChannelTypes.includes(channel.type)) {
|
if (!(channel.type in TextBasedChannelTypes)) {
|
||||||
this.client.emit(Events.WARN, `Discord sent a typing packet to a ${channel.type} channel ${channel.id}`);
|
this.client.emit(Events.WARN, `Discord sent a typing packet to a ${channel.type} channel ${channel.id}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,8 +80,8 @@ class GuildChannelManager extends CachedManager {
|
|||||||
/**
|
/**
|
||||||
* Options used to create a new channel in a guild.
|
* Options used to create a new channel in a guild.
|
||||||
* @typedef {Object} GuildChannelCreateOptions
|
* @typedef {Object} GuildChannelCreateOptions
|
||||||
* @property {string} [type='text'] The type of the new channel, either `text`, `voice`, `category`, `news`,
|
* @property {string|number} [type='GUILD_TEXT'] The type of the new channel, either `GUILD_TEXT`, `GUILD_VOICE`,
|
||||||
* `store`, or `stage`
|
* `GUILD_CATEGORY`, `GUILD_NEWS`, `GUILD_STORE`, or `GUILD_STAGE_VOICE`
|
||||||
* @property {string} [topic] The topic for the new channel
|
* @property {string} [topic] The topic for the new channel
|
||||||
* @property {boolean} [nsfw] Whether the new channel is nsfw
|
* @property {boolean} [nsfw] Whether the new channel is nsfw
|
||||||
* @property {number} [bitrate] Bitrate of the new channel in bits (only voice)
|
* @property {number} [bitrate] Bitrate of the new channel in bits (only voice)
|
||||||
@@ -107,7 +107,7 @@ class GuildChannelManager extends CachedManager {
|
|||||||
* @example
|
* @example
|
||||||
* // Create a new channel with permission overwrites
|
* // Create a new channel with permission overwrites
|
||||||
* guild.channels.create('new-voice', {
|
* guild.channels.create('new-voice', {
|
||||||
* type: 'voice',
|
* type: 'GUILD_VOICE',
|
||||||
* permissionOverwrites: [
|
* permissionOverwrites: [
|
||||||
* {
|
* {
|
||||||
* id: message.author.id,
|
* id: message.author.id,
|
||||||
@@ -129,7 +129,7 @@ class GuildChannelManager extends CachedManager {
|
|||||||
data: {
|
data: {
|
||||||
name,
|
name,
|
||||||
topic,
|
topic,
|
||||||
type: type ? ChannelTypes[type.toUpperCase()] : ChannelTypes.TEXT,
|
type: typeof type === 'number' ? type : ChannelTypes[type] ?? ChannelTypes.GUILD_TEXT,
|
||||||
nsfw,
|
nsfw,
|
||||||
bitrate,
|
bitrate,
|
||||||
user_limit: userLimit,
|
user_limit: userLimit,
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class GuildManager extends CachedManager {
|
|||||||
* @property {Snowflake|number} [id] The channel's id, used to set its parent,
|
* @property {Snowflake|number} [id] The channel's id, used to set its parent,
|
||||||
* this is a placeholder and will be replaced by the API after consumption
|
* this is a placeholder and will be replaced by the API after consumption
|
||||||
* @property {Snowflake|number} [parentId] The parent id for this channel
|
* @property {Snowflake|number} [parentId] The parent id for this channel
|
||||||
* @property {string} [type] The type of the channel
|
* @property {ChannelType} [type] The type of the channel
|
||||||
* @property {string} name The name of the channel
|
* @property {string} name The name of the channel
|
||||||
* @property {string} [topic] The topic of the text channel
|
* @property {string} [topic] The topic of the text channel
|
||||||
* @property {boolean} [nsfw] Whether the channel is NSFW
|
* @property {boolean} [nsfw] Whether the channel is NSFW
|
||||||
|
|||||||
@@ -77,9 +77,9 @@ class ThreadManager extends CachedManager {
|
|||||||
* should automatically archive in case of no recent activity
|
* should automatically archive in case of no recent activity
|
||||||
* @property {MessageResolvable} [startMessage] The message to start a thread from. <warn>If this is defined then type
|
* @property {MessageResolvable} [startMessage] The message to start a thread from. <warn>If this is defined then type
|
||||||
* of thread gets automatically defined and cannot be changed. The provided `type` field will be ignored</warn>
|
* of thread gets automatically defined and cannot be changed. The provided `type` field will be ignored</warn>
|
||||||
* @property {ThreadChannelType|number} [type] The type of thread to create. Defaults to `public_thread` if created in
|
* @property {ThreadChannelTypes|number} [type] The type of thread to create. Defaults to `GUILD_PUBLIC_THREAD` if
|
||||||
* a {@link TextChannel} <warn>When creating threads in a {@link NewsChannel} this is ignored and is always
|
* created in a {@link TextChannel} <warn>When creating threads in a {@link NewsChannel} this is ignored and is always
|
||||||
* `news_thread`</warn>
|
* `GUILD_NEWS_THREAD`</warn>
|
||||||
* @property {string} [reason] Reason for creating the thread
|
* @property {string} [reason] Reason for creating the thread
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ class ThreadManager extends CachedManager {
|
|||||||
* .create({
|
* .create({
|
||||||
* name: 'mod-talk',
|
* name: 'mod-talk',
|
||||||
* autoArchiveDuration: 60,
|
* autoArchiveDuration: 60,
|
||||||
* type: 'private_thread',
|
* type: 'GUILD_PRIVATE_THREAD',
|
||||||
* reason: 'Needed a separate thread for moderation',
|
* reason: 'Needed a separate thread for moderation',
|
||||||
* })
|
* })
|
||||||
* .then(threadChannel => console.log(threadChannel))
|
* .then(threadChannel => console.log(threadChannel))
|
||||||
@@ -114,13 +114,14 @@ class ThreadManager extends CachedManager {
|
|||||||
if (type && typeof type !== 'string' && typeof type !== 'number') {
|
if (type && typeof type !== 'string' && typeof type !== 'number') {
|
||||||
throw new TypeError('INVALID_TYPE', 'type', 'ThreadChannelType or Number');
|
throw new TypeError('INVALID_TYPE', 'type', 'ThreadChannelType or Number');
|
||||||
}
|
}
|
||||||
let resolvedType = this.channel.type === 'news' ? ChannelTypes.NEWS_THREAD : ChannelTypes.PUBLIC_THREAD;
|
let resolvedType =
|
||||||
|
this.channel.type === 'GUILD_NEWS' ? ChannelTypes.GUILD_NEWS_THREAD : ChannelTypes.GUILD_PUBLIC_THREAD;
|
||||||
if (startMessage) {
|
if (startMessage) {
|
||||||
const startMessageId = this.channel.messages.resolveId(startMessage);
|
const startMessageId = this.channel.messages.resolveId(startMessage);
|
||||||
if (!startMessageId) throw new TypeError('INVALID_TYPE', 'startMessage', 'MessageResolvable');
|
if (!startMessageId) throw new TypeError('INVALID_TYPE', 'startMessage', 'MessageResolvable');
|
||||||
path = path.messages(startMessageId);
|
path = path.messages(startMessageId);
|
||||||
} else if (this.channel.type !== 'news') {
|
} else if (this.channel.type !== 'GUILD_NEWS') {
|
||||||
resolvedType = typeof type === 'string' ? ChannelTypes[type.toUpperCase()] : type ?? resolvedType;
|
resolvedType = typeof type === 'string' ? ChannelTypes[type] : type ?? resolvedType;
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await path.threads.post({
|
const data = await path.threads.post({
|
||||||
|
|||||||
@@ -23,21 +23,10 @@ class Channel extends Base {
|
|||||||
|
|
||||||
const type = ChannelTypes[data.type];
|
const type = ChannelTypes[data.type];
|
||||||
/**
|
/**
|
||||||
* The type of the channel, either:
|
* The type of the channel
|
||||||
* * `dm` - a DM channel
|
* @type {ChannelType}
|
||||||
* * `text` - a guild text channel
|
|
||||||
* * `voice` - a guild voice channel
|
|
||||||
* * `category` - a guild category channel
|
|
||||||
* * `news` - a guild news channel
|
|
||||||
* * `store` - a guild store channel
|
|
||||||
* * `news_thread` - a guild news channel's public thread channel
|
|
||||||
* * `public_thread` - a guild text channel's public thread channel
|
|
||||||
* * `private_thread` - a guild text channel's private thread channel
|
|
||||||
* * `stage` - a guild stage channel
|
|
||||||
* * `unknown` - a generic channel of unknown type, could be Channel or GuildChannel
|
|
||||||
* @type {string}
|
|
||||||
*/
|
*/
|
||||||
this.type = type?.toLowerCase() ?? 'unknown';
|
this.type = type ?? 'UNKNOWN';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the channel has been deleted
|
* Whether the channel has been deleted
|
||||||
@@ -139,9 +128,9 @@ class Channel extends Base {
|
|||||||
|
|
||||||
let channel;
|
let channel;
|
||||||
if (!data.guild_id && !guild) {
|
if (!data.guild_id && !guild) {
|
||||||
if ((data.recipients && data.type !== ChannelTypes.GROUP) || data.type === ChannelTypes.DM) {
|
if ((data.recipients && data.type !== ChannelTypes.GROUP_DM) || data.type === ChannelTypes.DM) {
|
||||||
channel = new DMChannel(client, data);
|
channel = new DMChannel(client, data);
|
||||||
} else if (data.type === ChannelTypes.GROUP) {
|
} else if (data.type === ChannelTypes.GROUP_DM) {
|
||||||
const PartialGroupDMChannel = require('./PartialGroupDMChannel');
|
const PartialGroupDMChannel = require('./PartialGroupDMChannel');
|
||||||
channel = new PartialGroupDMChannel(client, data);
|
channel = new PartialGroupDMChannel(client, data);
|
||||||
}
|
}
|
||||||
@@ -150,33 +139,33 @@ class Channel extends Base {
|
|||||||
|
|
||||||
if (guild || allowUnknownGuild) {
|
if (guild || allowUnknownGuild) {
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case ChannelTypes.TEXT: {
|
case ChannelTypes.GUILD_TEXT: {
|
||||||
channel = new TextChannel(guild, data, client);
|
channel = new TextChannel(guild, data, client);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ChannelTypes.VOICE: {
|
case ChannelTypes.GUILD_VOICE: {
|
||||||
channel = new VoiceChannel(guild, data, client);
|
channel = new VoiceChannel(guild, data, client);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ChannelTypes.CATEGORY: {
|
case ChannelTypes.GUILD_CATEGORY: {
|
||||||
channel = new CategoryChannel(guild, data, client);
|
channel = new CategoryChannel(guild, data, client);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ChannelTypes.NEWS: {
|
case ChannelTypes.GUILD_NEWS: {
|
||||||
channel = new NewsChannel(guild, data, client);
|
channel = new NewsChannel(guild, data, client);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ChannelTypes.STORE: {
|
case ChannelTypes.GUILD_STORE: {
|
||||||
channel = new StoreChannel(guild, data, client);
|
channel = new StoreChannel(guild, data, client);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ChannelTypes.STAGE: {
|
case ChannelTypes.GUILD_STAGE_VOICE: {
|
||||||
channel = new StageChannel(guild, data, client);
|
channel = new StageChannel(guild, data, client);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ChannelTypes.NEWS_THREAD:
|
case ChannelTypes.GUILD_NEWS_THREAD:
|
||||||
case ChannelTypes.PUBLIC_THREAD:
|
case ChannelTypes.GUILD_PUBLIC_THREAD:
|
||||||
case ChannelTypes.PRIVATE_THREAD: {
|
case ChannelTypes.GUILD_PRIVATE_THREAD: {
|
||||||
channel = new ThreadChannel(guild, data, client);
|
channel = new ThreadChannel(guild, data, client);
|
||||||
if (!allowUnknownGuild) channel.parent?.threads.cache.set(channel.id, channel);
|
if (!allowUnknownGuild) channel.parent?.threads.cache.set(channel.id, channel);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class DMChannel extends Channel {
|
|||||||
constructor(client, data) {
|
constructor(client, data) {
|
||||||
super(client, data);
|
super(client, data);
|
||||||
// Override the channel type so partials have a known type
|
// Override the channel type so partials have a known type
|
||||||
this.type = 'dm';
|
this.type = 'DM';
|
||||||
/**
|
/**
|
||||||
* A manager of the messages belonging to this channel
|
* A manager of the messages belonging to this channel
|
||||||
* @type {MessageManager}
|
* @type {MessageManager}
|
||||||
|
|||||||
@@ -1358,12 +1358,12 @@ class Guild extends AnonymousGuild {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_sortedChannels(channel) {
|
_sortedChannels(channel) {
|
||||||
const category = channel.type === ChannelTypes.CATEGORY;
|
const category = channel.type === ChannelTypes.GUILD_CATEGORY;
|
||||||
return Util.discordSort(
|
return Util.discordSort(
|
||||||
this.channels.cache.filter(
|
this.channels.cache.filter(
|
||||||
c =>
|
c =>
|
||||||
(['text', 'news', 'store'].includes(channel.type)
|
(['GUILD_TEXT', 'GUILD_NEWS', 'GUILD_STORE'].includes(channel.type)
|
||||||
? ['text', 'news', 'store'].includes(c.type)
|
? ['GUILD_TEXT', 'GUILD_NEWS', 'GUILD_STORE'].includes(c.type)
|
||||||
: c.type === channel.type) &&
|
: c.type === channel.type) &&
|
||||||
(category || c.parent === channel.parent),
|
(category || c.parent === channel.parent),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const PermissionOverwrites = require('./PermissionOverwrites');
|
|||||||
const { Error } = require('../errors');
|
const { Error } = require('../errors');
|
||||||
const PermissionOverwriteManager = require('../managers/PermissionOverwriteManager');
|
const PermissionOverwriteManager = require('../managers/PermissionOverwriteManager');
|
||||||
const Collection = require('../util/Collection');
|
const Collection = require('../util/Collection');
|
||||||
const { ChannelTypes } = require('../util/Constants');
|
const { ChannelTypes, VoiceBasedChannelTypes } = require('../util/Constants');
|
||||||
const Permissions = require('../util/Permissions');
|
const Permissions = require('../util/Permissions');
|
||||||
const Util = require('../util/Util');
|
const Util = require('../util/Util');
|
||||||
|
|
||||||
@@ -265,7 +265,7 @@ class GuildChannel extends Channel {
|
|||||||
* The data for a guild channel.
|
* The data for a guild channel.
|
||||||
* @typedef {Object} ChannelData
|
* @typedef {Object} ChannelData
|
||||||
* @property {string} [name] The name of the channel
|
* @property {string} [name] The name of the channel
|
||||||
* @property {string} [type] The type of the the channel (only conversion between text and news is supported)
|
* @property {ChannelType} [type] The type of the the channel (only conversion between text and news is supported)
|
||||||
* @property {number} [position] The position of the channel
|
* @property {number} [position] The position of the channel
|
||||||
* @property {string} [topic] The topic of the text channel
|
* @property {string} [topic] The topic of the text channel
|
||||||
* @property {boolean} [nsfw] Whether the channel is NSFW
|
* @property {boolean} [nsfw] Whether the channel is NSFW
|
||||||
@@ -319,7 +319,7 @@ class GuildChannel extends Channel {
|
|||||||
if (data.lockPermissions) {
|
if (data.lockPermissions) {
|
||||||
if (data.parentId) {
|
if (data.parentId) {
|
||||||
const newParent = this.guild.channels.resolve(data.parentId);
|
const newParent = this.guild.channels.resolve(data.parentId);
|
||||||
if (newParent?.type === 'category') {
|
if (newParent?.type === 'GUILD_CATEGORY') {
|
||||||
permission_overwrites = newParent.permissionOverwrites.cache.map(o =>
|
permission_overwrites = newParent.permissionOverwrites.cache.map(o =>
|
||||||
PermissionOverwrites.resolve(o, this.guild),
|
PermissionOverwrites.resolve(o, this.guild),
|
||||||
);
|
);
|
||||||
@@ -334,7 +334,7 @@ class GuildChannel extends Channel {
|
|||||||
const newData = await this.client.api.channels(this.id).patch({
|
const newData = await this.client.api.channels(this.id).patch({
|
||||||
data: {
|
data: {
|
||||||
name: (data.name ?? this.name).trim(),
|
name: (data.name ?? this.name).trim(),
|
||||||
type: ChannelTypes[data.type?.toUpperCase()],
|
type: ChannelTypes[data.type],
|
||||||
topic: data.topic,
|
topic: data.topic,
|
||||||
nsfw: data.nsfw,
|
nsfw: data.nsfw,
|
||||||
bitrate: data.bitrate ?? this.bitrate,
|
bitrate: data.bitrate ?? this.bitrate,
|
||||||
@@ -567,7 +567,7 @@ class GuildChannel extends Channel {
|
|||||||
*/
|
*/
|
||||||
get manageable() {
|
get manageable() {
|
||||||
if (this.client.user.id === this.guild.ownerId) return true;
|
if (this.client.user.id === this.guild.ownerId) return true;
|
||||||
if (this.type === 'voice' || this.type === 'stage') {
|
if (this.type in VoiceBasedChannelTypes) {
|
||||||
if (!this.permissionsFor(this.client.user).has(Permissions.FLAGS.CONNECT, false)) {
|
if (!this.permissionsFor(this.client.user).has(Permissions.FLAGS.CONNECT, false)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -552,7 +552,7 @@ class Message extends Base {
|
|||||||
*/
|
*/
|
||||||
get crosspostable() {
|
get crosspostable() {
|
||||||
return (
|
return (
|
||||||
this.channel.type === 'news' &&
|
this.channel.type === 'GUILD_NEWS' &&
|
||||||
!this.flags.has(MessageFlags.FLAGS.CROSSPOSTED) &&
|
!this.flags.has(MessageFlags.FLAGS.CROSSPOSTED) &&
|
||||||
this.type === 'DEFAULT' &&
|
this.type === 'DEFAULT' &&
|
||||||
this.channel.viewable &&
|
this.channel.viewable &&
|
||||||
@@ -595,7 +595,7 @@ class Message extends Base {
|
|||||||
* @returns {Promise<Message>}
|
* @returns {Promise<Message>}
|
||||||
* @example
|
* @example
|
||||||
* // Crosspost a message
|
* // Crosspost a message
|
||||||
* if (message.channel.type === 'news') {
|
* if (message.channel.type === 'GUILD_NEWS') {
|
||||||
* message.crosspost()
|
* message.crosspost()
|
||||||
* .then(() => console.log('Crossposted message'))
|
* .then(() => console.log('Crossposted message'))
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
@@ -713,7 +713,7 @@ class Message extends Base {
|
|||||||
* @returns {Promise<ThreadChannel>}
|
* @returns {Promise<ThreadChannel>}
|
||||||
*/
|
*/
|
||||||
startThread(name, autoArchiveDuration, reason) {
|
startThread(name, autoArchiveDuration, reason) {
|
||||||
if (!['text', 'news'].includes(this.channel.type)) {
|
if (!['GUILD_TEXT', 'GUILD_NEWS'].includes(this.channel.type)) {
|
||||||
return Promise.reject(new Error('MESSAGE_THREAD_PARENT'));
|
return Promise.reject(new Error('MESSAGE_THREAD_PARENT'));
|
||||||
}
|
}
|
||||||
return this.channel.threads.create({ name, autoArchiveDuration, startMessage: this, reason });
|
return this.channel.threads.create({ name, autoArchiveDuration, startMessage: this, reason });
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ class MessageMentions {
|
|||||||
this.crosspostedChannels.set(d.id, {
|
this.crosspostedChannels.set(d.id, {
|
||||||
channelId: d.id,
|
channelId: d.id,
|
||||||
guildId: d.guild_id,
|
guildId: d.guild_id,
|
||||||
type: type?.toLowerCase() ?? 'unknown',
|
type: type ?? 'UNKNOWN',
|
||||||
name: d.name,
|
name: d.name,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class NewsChannel extends TextChannel {
|
|||||||
* @param {string} [reason] Reason for creating the webhook
|
* @param {string} [reason] Reason for creating the webhook
|
||||||
* @returns {Promise<NewsChannel>}
|
* @returns {Promise<NewsChannel>}
|
||||||
* @example
|
* @example
|
||||||
* if (channel.type === 'news') {
|
* if (channel.type === 'GUILD_NEWS') {
|
||||||
* channel.addFollower('222197033908436994', 'Important announcements')
|
* channel.addFollower('222197033908436994', 'Important announcements')
|
||||||
* .then(() => console.log('Added follower'))
|
* .then(() => console.log('Added follower'))
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
|
|||||||
@@ -346,7 +346,7 @@ class ThreadChannel extends Channel {
|
|||||||
!this.archived &&
|
!this.archived &&
|
||||||
!this.joined &&
|
!this.joined &&
|
||||||
this.permissionsFor(this.client.user)?.has(
|
this.permissionsFor(this.client.user)?.has(
|
||||||
this.type === 'private_thread' ? Permissions.FLAGS.MANAGE_THREADS : Permissions.FLAGS.VIEW_CHANNEL,
|
this.type === 'GUILD_PRIVATE_THREAD' ? Permissions.FLAGS.MANAGE_THREADS : Permissions.FLAGS.VIEW_CHANNEL,
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -373,7 +373,9 @@ class ThreadChannel extends Channel {
|
|||||||
this.permissionsFor(this.client.user)?.any(
|
this.permissionsFor(this.client.user)?.any(
|
||||||
[
|
[
|
||||||
Permissions.FLAGS.SEND_MESSAGES,
|
Permissions.FLAGS.SEND_MESSAGES,
|
||||||
this.type === 'private_thread' ? Permissions.FLAGS.USE_PRIVATE_THREADS : Permissions.FLAGS.USE_PUBLIC_THREADS,
|
this.type === 'GUILD_PRIVATE_THREAD'
|
||||||
|
? Permissions.FLAGS.USE_PRIVATE_THREADS
|
||||||
|
: Permissions.FLAGS.USE_PUBLIC_THREADS,
|
||||||
],
|
],
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ class User extends Base {
|
|||||||
* @readonly
|
* @readonly
|
||||||
*/
|
*/
|
||||||
get dmChannel() {
|
get dmChannel() {
|
||||||
return this.client.channels.cache.find(c => c.type === 'dm' && c.recipient.id === this.id) ?? null;
|
return this.client.channels.cache.find(c => c.type === 'DM' && c.recipient.id === this.id) ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ class VoiceState extends Base {
|
|||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
async setRequestToSpeak(request) {
|
async setRequestToSpeak(request) {
|
||||||
if (this.channel?.type !== 'stage') throw new Error('VOICE_NOT_STAGE_CHANNEL');
|
if (this.channel?.type !== 'GUILD_STAGE_VOICE') throw new Error('VOICE_NOT_STAGE_CHANNEL');
|
||||||
|
|
||||||
if (this.client.user.id !== this.id) throw new Error('VOICE_STATE_NOT_OWN');
|
if (this.client.user.id !== this.id) throw new Error('VOICE_STATE_NOT_OWN');
|
||||||
|
|
||||||
@@ -203,7 +203,7 @@ class VoiceState extends Base {
|
|||||||
async setSuppressed(suppressed) {
|
async setSuppressed(suppressed) {
|
||||||
if (typeof suppressed !== 'boolean') throw new TypeError('VOICE_STATE_INVALID_TYPE', 'suppressed');
|
if (typeof suppressed !== 'boolean') throw new TypeError('VOICE_STATE_INVALID_TYPE', 'suppressed');
|
||||||
|
|
||||||
if (this.channel?.type !== 'stage') throw new Error('VOICE_NOT_STAGE_CHANNEL');
|
if (this.channel?.type !== 'GUILD_STAGE_VOICE') throw new Error('VOICE_NOT_STAGE_CHANNEL');
|
||||||
|
|
||||||
const target = this.client.user.id === this.id ? '@me' : this.id;
|
const target = this.client.user.id === this.id ? '@me' : this.id;
|
||||||
|
|
||||||
|
|||||||
@@ -415,31 +415,73 @@ exports.SystemMessageTypes = exports.MessageTypes.filter(
|
|||||||
*/
|
*/
|
||||||
exports.ActivityTypes = createEnum(['PLAYING', 'STREAMING', 'LISTENING', 'WATCHING', 'CUSTOM', 'COMPETING']);
|
exports.ActivityTypes = createEnum(['PLAYING', 'STREAMING', 'LISTENING', 'WATCHING', 'CUSTOM', 'COMPETING']);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All available channel types:
|
||||||
|
* * `GUILD_TEXT` - a guild text channel
|
||||||
|
* * `DM` - a DM channel
|
||||||
|
* * `GUILD_VOICE` - a guild voice channel
|
||||||
|
* * `GROUP_DM` - a group DM channel
|
||||||
|
* * `GUILD_CATEGORY` - a guild category channel
|
||||||
|
* * `GUILD_NEWS` - a guild news channel
|
||||||
|
* * `GUILD_STORE` - a guild store channel
|
||||||
|
* * `GUILD_NEWS_THREAD` - a guild news channel's public thread channel
|
||||||
|
* * `GUILD_PUBLIC_THREAD` - a guild text channel's public thread channel
|
||||||
|
* * `GUILD_PRIVATE_THREAD` - a guild text channel's private thread channel
|
||||||
|
* * `GUILD_STAGE_VOICE` - a guild stage voice channel
|
||||||
|
* * `UNKNOWN` - a generic channel of unknown type, could be Channel or GuildChannel
|
||||||
|
* @typedef {string} ChannelType
|
||||||
|
*/
|
||||||
exports.ChannelTypes = createEnum([
|
exports.ChannelTypes = createEnum([
|
||||||
'TEXT',
|
'GUILD_TEXT',
|
||||||
'DM',
|
'DM',
|
||||||
'VOICE',
|
'GUILD_VOICE',
|
||||||
'GROUP',
|
'GROUP_DM',
|
||||||
'CATEGORY',
|
'GUILD_CATEGORY',
|
||||||
'NEWS',
|
'GUILD_NEWS',
|
||||||
// 6
|
'GUILD_STORE',
|
||||||
'STORE',
|
|
||||||
...Array(3).fill(null),
|
...Array(3).fill(null),
|
||||||
// 10
|
// 10
|
||||||
'NEWS_THREAD',
|
'GUILD_NEWS_THREAD',
|
||||||
'PUBLIC_THREAD',
|
'GUILD_PUBLIC_THREAD',
|
||||||
'PRIVATE_THREAD',
|
'GUILD_PRIVATE_THREAD',
|
||||||
'STAGE',
|
'GUILD_STAGE_VOICE',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The types of channels that are threads. The available types are:
|
* The types of channels that are text-based. The available types are:
|
||||||
* * news_thread
|
* * DM
|
||||||
* * public_thread
|
* * GUILD_TEXT
|
||||||
* * private_thread
|
* * GUILD_NEWS
|
||||||
* @typedef {string} ThreadChannelType
|
* * GUILD_NEWS_THREAD
|
||||||
|
* * GUILD_PUBLIC_THREAD
|
||||||
|
* * GUILD_PRIVATE_THREAD
|
||||||
|
* @typedef {string} TextBasedChannelTypes
|
||||||
*/
|
*/
|
||||||
exports.ThreadChannelTypes = ['news_thread', 'public_thread', 'private_thread'];
|
exports.TextBasedChannelTypes = [
|
||||||
|
'DM',
|
||||||
|
'GUILD_TEXT',
|
||||||
|
'GUILD_NEWS',
|
||||||
|
'GUILD_NEWS_THREAD',
|
||||||
|
'GUILD_PUBLIC_THREAD',
|
||||||
|
'GUILD_PRIVATE_THREAD',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The types of channels that are threads. The available types are:
|
||||||
|
* * GUILD_NEWS_THREAD
|
||||||
|
* * GUILD_PUBLIC_THREAD
|
||||||
|
* * GUILD_PRIVATE_THREAD
|
||||||
|
* @typedef {string} ThreadChannelTypes
|
||||||
|
*/
|
||||||
|
exports.ThreadChannelTypes = ['GUILD_NEWS_THREAD', 'GUILD_PUBLIC_THREAD', 'GUILD_PRIVATE_THREAD'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The types of channels that are voice-based. The available types are:
|
||||||
|
* * GUILD_VOICE
|
||||||
|
* * GUILD_STAGE_VOICE
|
||||||
|
* @typedef {string} VoiceBasedChannelTypes
|
||||||
|
*/
|
||||||
|
exports.VoiceBasedChannelTypes = ['GUILD_VOICE', 'GUILD_STAGE_VOICE'];
|
||||||
|
|
||||||
exports.ClientApplicationAssetTypes = {
|
exports.ClientApplicationAssetTypes = {
|
||||||
SMALL: 1,
|
SMALL: 1,
|
||||||
|
|||||||
@@ -582,7 +582,7 @@ class Util extends null {
|
|||||||
str = str
|
str = str
|
||||||
.replace(/<@!?[0-9]+>/g, input => {
|
.replace(/<@!?[0-9]+>/g, input => {
|
||||||
const id = input.replace(/<|!|>|@/g, '');
|
const id = input.replace(/<|!|>|@/g, '');
|
||||||
if (channel.type === 'dm') {
|
if (channel.type === 'DM') {
|
||||||
const user = channel.client.users.cache.get(id);
|
const user = channel.client.users.cache.get(id);
|
||||||
return user ? Util.removeMentions(`@${user.username}`) : input;
|
return user ? Util.removeMentions(`@${user.username}`) : input;
|
||||||
}
|
}
|
||||||
@@ -600,7 +600,7 @@ class Util extends null {
|
|||||||
return mentionedChannel ? `#${mentionedChannel.name}` : input;
|
return mentionedChannel ? `#${mentionedChannel.name}` : input;
|
||||||
})
|
})
|
||||||
.replace(/<@&[0-9]+>/g, input => {
|
.replace(/<@&[0-9]+>/g, input => {
|
||||||
if (channel.type === 'dm') return input;
|
if (channel.type === 'DM') return input;
|
||||||
const role = channel.guild.roles.cache.get(input.replace(/<|@|>|&/g, ''));
|
const role = channel.guild.roles.cache.get(input.replace(/<|@|>|&/g, ''));
|
||||||
return role ? `@${role.name}` : input;
|
return role ? `@${role.name}` : input;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ client.on('ready', async () => {
|
|||||||
try {
|
try {
|
||||||
const guild = await client.guilds.create('testing', {
|
const guild = await client.guilds.create('testing', {
|
||||||
channels: [
|
channels: [
|
||||||
{ name: 'afk channel', type: 'voice', id: 0 },
|
{ name: 'afk channel', type: 'GUILD_VOICE', id: 0 },
|
||||||
{ name: 'system-channel', id: 1 },
|
{ name: 'system-channel', id: 1 },
|
||||||
],
|
],
|
||||||
afkChannelId: 0,
|
afkChannelId: 0,
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ client.on('messageCreate', message => {
|
|||||||
if (true) {
|
if (true) {
|
||||||
if (message.content === 'makechann') {
|
if (message.content === 'makechann') {
|
||||||
if (message.channel.guild) {
|
if (message.channel.guild) {
|
||||||
message.channel.guild.channels.create('hi', { type: 'text' }).then(console.log);
|
message.channel.guild.channels.create('hi', { type: 'GUILD_TEXT' }).then(console.log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
36
typings/enums.d.ts
vendored
36
typings/enums.d.ts
vendored
@@ -27,33 +27,19 @@ export enum ApplicationCommandPermissionTypes {
|
|||||||
USER = 2,
|
USER = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ChannelType {
|
|
||||||
text = 0,
|
|
||||||
dm = 1,
|
|
||||||
voice = 2,
|
|
||||||
group = 3,
|
|
||||||
category = 4,
|
|
||||||
news = 5,
|
|
||||||
store = 6,
|
|
||||||
unknown = 7,
|
|
||||||
news_thread = 10,
|
|
||||||
public_thread = 11,
|
|
||||||
private_thread = 12,
|
|
||||||
stage = 13,
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum ChannelTypes {
|
export enum ChannelTypes {
|
||||||
TEXT = 0,
|
GUILD_TEXT = 0,
|
||||||
DM = 1,
|
DM = 1,
|
||||||
VOICE = 2,
|
GUILD_VOICE = 2,
|
||||||
GROUP = 3,
|
GROUP_DM = 3,
|
||||||
CATEGORY = 4,
|
GUILD_CATEGORY = 4,
|
||||||
NEWS = 5,
|
GUILD_NEWS = 5,
|
||||||
STORE = 6,
|
GUILD_STORE = 6,
|
||||||
NEWS_THREAD = 10,
|
UNKNOWN = 7,
|
||||||
PUBLIC_THREAD = 11,
|
GUILD_NEWS_THREAD = 10,
|
||||||
PRIVATE_THREAD = 12,
|
GUILD_PUBLIC_THREAD = 11,
|
||||||
STAGE = 13,
|
GUILD_PRIVATE_THREAD = 12,
|
||||||
|
GUILD_STAGE_VOICE = 13,
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum DefaultMessageNotificationLevels {
|
export enum DefaultMessageNotificationLevels {
|
||||||
|
|||||||
93
typings/index.d.ts
vendored
93
typings/index.d.ts
vendored
@@ -37,7 +37,6 @@ import {
|
|||||||
ActivityTypes,
|
ActivityTypes,
|
||||||
ApplicationCommandOptionTypes,
|
ApplicationCommandOptionTypes,
|
||||||
ApplicationCommandPermissionTypes,
|
ApplicationCommandPermissionTypes,
|
||||||
ChannelType,
|
|
||||||
ChannelTypes,
|
ChannelTypes,
|
||||||
ConstantsClientApplicationAssetTypes,
|
ConstantsClientApplicationAssetTypes,
|
||||||
ConstantsColors,
|
ConstantsColors,
|
||||||
@@ -259,7 +258,7 @@ export class ButtonInteraction extends MessageComponentInteraction {
|
|||||||
|
|
||||||
export class CategoryChannel extends GuildChannel {
|
export class CategoryChannel extends GuildChannel {
|
||||||
public readonly children: Collection<Snowflake, GuildChannel>;
|
public readonly children: Collection<Snowflake, GuildChannel>;
|
||||||
public type: 'category';
|
public type: 'GUILD_CATEGORY';
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CategoryChannelResolvable = Snowflake | CategoryChannel;
|
export type CategoryChannelResolvable = Snowflake | CategoryChannel;
|
||||||
@@ -270,7 +269,7 @@ export class Channel extends Base {
|
|||||||
public readonly createdTimestamp: number;
|
public readonly createdTimestamp: number;
|
||||||
public deleted: boolean;
|
public deleted: boolean;
|
||||||
public id: Snowflake;
|
public id: Snowflake;
|
||||||
public type: keyof typeof ChannelType;
|
public type: keyof typeof ChannelTypes;
|
||||||
public delete(): Promise<Channel>;
|
public delete(): Promise<Channel>;
|
||||||
public fetch(force?: boolean): Promise<Channel>;
|
public fetch(force?: boolean): Promise<Channel>;
|
||||||
public isText(): this is TextChannel | DMChannel | NewsChannel | ThreadChannel;
|
public isText(): this is TextChannel | DMChannel | NewsChannel | ThreadChannel;
|
||||||
@@ -458,7 +457,7 @@ export class DMChannel extends TextBasedChannel(Channel, ['bulkDelete']) {
|
|||||||
public messages: MessageManager;
|
public messages: MessageManager;
|
||||||
public recipient: User;
|
public recipient: User;
|
||||||
public readonly partial: false;
|
public readonly partial: false;
|
||||||
public type: 'dm';
|
public type: 'DM';
|
||||||
public fetch(force?: boolean): Promise<this>;
|
public fetch(force?: boolean): Promise<this>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -646,7 +645,7 @@ export class GuildChannel extends Channel {
|
|||||||
public readonly permissionsLocked: boolean | null;
|
public readonly permissionsLocked: boolean | null;
|
||||||
public readonly position: number;
|
public readonly position: number;
|
||||||
public rawPosition: number;
|
public rawPosition: number;
|
||||||
public type: Exclude<keyof typeof ChannelType, 'dm' | 'group' | 'unknown'>;
|
public type: Exclude<keyof typeof ChannelTypes, 'DM' | 'GROUP_DM' | 'UNKNOWN'>;
|
||||||
public readonly viewable: boolean;
|
public readonly viewable: boolean;
|
||||||
public clone(options?: GuildChannelCloneOptions): Promise<this>;
|
public clone(options?: GuildChannelCloneOptions): Promise<this>;
|
||||||
public createInvite(options?: CreateInviteOptions): Promise<Invite>;
|
public createInvite(options?: CreateInviteOptions): Promise<Invite>;
|
||||||
@@ -1229,14 +1228,14 @@ export class NewsChannel extends TextBasedChannel(GuildChannel) {
|
|||||||
public nsfw: boolean;
|
public nsfw: boolean;
|
||||||
public threads: ThreadManager<AllowedThreadTypeForNewsChannel>;
|
public threads: ThreadManager<AllowedThreadTypeForNewsChannel>;
|
||||||
public topic: string | null;
|
public topic: string | null;
|
||||||
public type: 'news';
|
public type: 'GUILD_NEWS';
|
||||||
public createWebhook(name: string, options?: ChannelWebhookCreateOptions): Promise<Webhook>;
|
public createWebhook(name: string, options?: ChannelWebhookCreateOptions): Promise<Webhook>;
|
||||||
public setDefaultAutoArchiveDuration(
|
public setDefaultAutoArchiveDuration(
|
||||||
defaultAutoArchiveDuration: ThreadAutoArchiveDuration,
|
defaultAutoArchiveDuration: ThreadAutoArchiveDuration,
|
||||||
reason?: string,
|
reason?: string,
|
||||||
): Promise<NewsChannel>;
|
): Promise<NewsChannel>;
|
||||||
public setNSFW(nsfw: boolean, reason?: string): Promise<NewsChannel>;
|
public setNSFW(nsfw: boolean, reason?: string): Promise<NewsChannel>;
|
||||||
public setType(type: Pick<typeof ChannelType, 'text' | 'news'>, reason?: string): Promise<GuildChannel>;
|
public setType(type: Pick<typeof ChannelTypes, 'GUILD_TEXT' | 'GUILD_NEWS'>, reason?: string): Promise<GuildChannel>;
|
||||||
public fetchWebhooks(): Promise<Collection<Snowflake, Webhook>>;
|
public fetchWebhooks(): Promise<Collection<Snowflake, Webhook>>;
|
||||||
public addFollower(channel: GuildChannelResolvable, reason?: string): Promise<NewsChannel>;
|
public addFollower(channel: GuildChannelResolvable, reason?: string): Promise<NewsChannel>;
|
||||||
}
|
}
|
||||||
@@ -1492,7 +1491,7 @@ export class SnowflakeUtil extends null {
|
|||||||
|
|
||||||
export class StageChannel extends BaseGuildVoiceChannel {
|
export class StageChannel extends BaseGuildVoiceChannel {
|
||||||
public topic: string | null;
|
public topic: string | null;
|
||||||
public type: 'stage';
|
public type: 'GUILD_STAGE_VOICE';
|
||||||
public readonly stageInstance: StageInstance | null;
|
public readonly stageInstance: StageInstance | null;
|
||||||
public createStageInstance(options: StageInstanceCreateOptions): Promise<StageInstance>;
|
public createStageInstance(options: StageInstanceCreateOptions): Promise<StageInstance>;
|
||||||
}
|
}
|
||||||
@@ -1532,7 +1531,7 @@ export class Sticker extends Base {
|
|||||||
export class StoreChannel extends GuildChannel {
|
export class StoreChannel extends GuildChannel {
|
||||||
public constructor(guild: Guild, data?: unknown, client?: Client);
|
public constructor(guild: Guild, data?: unknown, client?: Client);
|
||||||
public nsfw: boolean;
|
public nsfw: boolean;
|
||||||
public type: 'store';
|
public type: 'GUILD_STORE';
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SystemChannelFlags extends BitField<SystemChannelFlagsString> {
|
export class SystemChannelFlags extends BitField<SystemChannelFlagsString> {
|
||||||
@@ -1573,7 +1572,7 @@ export class TextChannel extends TextBasedChannel(GuildChannel) {
|
|||||||
public defaultAutoArchiveDuration?: ThreadAutoArchiveDuration;
|
public defaultAutoArchiveDuration?: ThreadAutoArchiveDuration;
|
||||||
public messages: MessageManager;
|
public messages: MessageManager;
|
||||||
public nsfw: boolean;
|
public nsfw: boolean;
|
||||||
public type: 'text';
|
public type: 'GUILD_TEXT';
|
||||||
public rateLimitPerUser: number;
|
public rateLimitPerUser: number;
|
||||||
public threads: ThreadManager<AllowedThreadTypeForTextChannel>;
|
public threads: ThreadManager<AllowedThreadTypeForTextChannel>;
|
||||||
public topic: string | null;
|
public topic: string | null;
|
||||||
@@ -1584,7 +1583,7 @@ export class TextChannel extends TextBasedChannel(GuildChannel) {
|
|||||||
): Promise<TextChannel>;
|
): Promise<TextChannel>;
|
||||||
public setNSFW(nsfw: boolean, reason?: string): Promise<TextChannel>;
|
public setNSFW(nsfw: boolean, reason?: string): Promise<TextChannel>;
|
||||||
public setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise<TextChannel>;
|
public setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise<TextChannel>;
|
||||||
public setType(type: Pick<typeof ChannelType, 'text' | 'news'>, reason?: string): Promise<GuildChannel>;
|
public setType(type: Pick<typeof ChannelTypes, 'GUILD_TEXT' | 'GUILD_NEWS'>, reason?: string): Promise<GuildChannel>;
|
||||||
public fetchWebhooks(): Promise<Collection<Snowflake, Webhook>>;
|
public fetchWebhooks(): Promise<Collection<Snowflake, Webhook>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1612,7 +1611,7 @@ export class ThreadChannel extends TextBasedChannel(Channel) {
|
|||||||
public readonly parent: TextChannel | NewsChannel | null;
|
public readonly parent: TextChannel | NewsChannel | null;
|
||||||
public parentId: Snowflake;
|
public parentId: Snowflake;
|
||||||
public rateLimitPerUser: number;
|
public rateLimitPerUser: number;
|
||||||
public type: ThreadChannelType;
|
public type: ThreadChannelTypes;
|
||||||
public readonly unarchivable: boolean;
|
public readonly unarchivable: boolean;
|
||||||
public delete(reason?: string): Promise<ThreadChannel>;
|
public delete(reason?: string): Promise<ThreadChannel>;
|
||||||
public edit(data: ThreadEditData, reason?: string): Promise<ThreadChannel>;
|
public edit(data: ThreadEditData, reason?: string): Promise<ThreadChannel>;
|
||||||
@@ -1742,7 +1741,7 @@ export class Formatters extends null {
|
|||||||
export class VoiceChannel extends BaseGuildVoiceChannel {
|
export class VoiceChannel extends BaseGuildVoiceChannel {
|
||||||
public readonly editable: boolean;
|
public readonly editable: boolean;
|
||||||
public readonly speakable: boolean;
|
public readonly speakable: boolean;
|
||||||
public type: 'voice';
|
public type: 'GUILD_VOICE';
|
||||||
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>;
|
||||||
}
|
}
|
||||||
@@ -2005,7 +2004,9 @@ export const Constants: {
|
|||||||
Opcodes: typeof ConstantsOpcodes;
|
Opcodes: typeof ConstantsOpcodes;
|
||||||
APIErrors: APIErrors;
|
APIErrors: APIErrors;
|
||||||
ChannelTypes: typeof ChannelTypes;
|
ChannelTypes: typeof ChannelTypes;
|
||||||
ThreadChannelTypes: ThreadChannelType[];
|
ThreadChannelTypes: ThreadChannelTypes[];
|
||||||
|
TextBasedChannelTypes: TextBasedChannelTypes[];
|
||||||
|
VoiceBasedChannelTypes: VoiceBasedChannelTypes[];
|
||||||
ClientApplicationAssetTypes: typeof ConstantsClientApplicationAssetTypes;
|
ClientApplicationAssetTypes: typeof ConstantsClientApplicationAssetTypes;
|
||||||
InviteScopes: InviteScope[];
|
InviteScopes: InviteScope[];
|
||||||
MessageTypes: MessageType[];
|
MessageTypes: MessageType[];
|
||||||
@@ -2168,12 +2169,18 @@ export class GuildChannelManager extends CachedManager<
|
|||||||
public constructor(guild: Guild, iterable?: Iterable<unknown>);
|
public constructor(guild: Guild, iterable?: Iterable<unknown>);
|
||||||
public readonly channelCountWithoutThreads: number;
|
public readonly channelCountWithoutThreads: number;
|
||||||
public guild: Guild;
|
public guild: Guild;
|
||||||
public create(name: string, options: GuildChannelCreateOptions & { type: 'voice' }): Promise<VoiceChannel>;
|
public create(name: string, options: GuildChannelCreateOptions & { type: 'GUILD_VOICE' }): Promise<VoiceChannel>;
|
||||||
public create(name: string, options: GuildChannelCreateOptions & { type: 'category' }): Promise<CategoryChannel>;
|
public create(
|
||||||
public create(name: string, options?: GuildChannelCreateOptions & { type?: 'text' }): Promise<TextChannel>;
|
name: string,
|
||||||
public create(name: string, options: GuildChannelCreateOptions & { type: 'news' }): Promise<NewsChannel>;
|
options: GuildChannelCreateOptions & { type: 'GUILD_CATEGORY' },
|
||||||
public create(name: string, options: GuildChannelCreateOptions & { type: 'store' }): Promise<StoreChannel>;
|
): Promise<CategoryChannel>;
|
||||||
public create(name: string, options: GuildChannelCreateOptions & { type: 'stage' }): Promise<StageChannel>;
|
public create(name: string, options?: GuildChannelCreateOptions & { type?: 'GUILD_TEXT' }): Promise<TextChannel>;
|
||||||
|
public create(name: string, options: GuildChannelCreateOptions & { type: 'GUILD_NEWS' }): Promise<NewsChannel>;
|
||||||
|
public create(name: string, options: GuildChannelCreateOptions & { type: 'GUILD_STORE' }): Promise<StoreChannel>;
|
||||||
|
public create(
|
||||||
|
name: string,
|
||||||
|
options: GuildChannelCreateOptions & { type: 'GUILD_STAGE_VOICE' },
|
||||||
|
): Promise<StageChannel>;
|
||||||
public create(
|
public create(
|
||||||
name: string,
|
name: string,
|
||||||
options: GuildChannelCreateOptions,
|
options: GuildChannelCreateOptions,
|
||||||
@@ -2486,9 +2493,9 @@ export interface AddGuildMemberOptions {
|
|||||||
|
|
||||||
export type AllowedImageFormat = 'webp' | 'png' | 'jpg' | 'jpeg' | 'gif';
|
export type AllowedImageFormat = 'webp' | 'png' | 'jpg' | 'jpeg' | 'gif';
|
||||||
|
|
||||||
export type AllowedThreadTypeForNewsChannel = 'news_thread' | 10;
|
export type AllowedThreadTypeForNewsChannel = 'GUILD_NEWS_THREAD' | 10;
|
||||||
|
|
||||||
export type AllowedThreadTypeForTextChannel = 'public_thread' | 'private_thread' | 11 | 12;
|
export type AllowedThreadTypeForTextChannel = 'GUILD_PUBLIC_THREAD' | 'GUILD_PRIVATE_THREAD' | 11 | 12;
|
||||||
|
|
||||||
export interface APIErrors {
|
export interface APIErrors {
|
||||||
UNKNOWN_ACCOUNT: 10001;
|
UNKNOWN_ACCOUNT: 10001;
|
||||||
@@ -2727,7 +2734,7 @@ export interface ChannelCreationOverwrites {
|
|||||||
|
|
||||||
export interface ChannelData {
|
export interface ChannelData {
|
||||||
name?: string;
|
name?: string;
|
||||||
type?: Pick<typeof ChannelType, 'text' | 'news'>;
|
type?: Pick<typeof ChannelTypes, 'GUILD_TEXT' | 'GUILD_NEWS'>;
|
||||||
position?: number;
|
position?: number;
|
||||||
topic?: string;
|
topic?: string;
|
||||||
nsfw?: boolean;
|
nsfw?: boolean;
|
||||||
@@ -2957,7 +2964,7 @@ export interface StageInstanceCreateOptions {
|
|||||||
export interface CrosspostedChannel {
|
export interface CrosspostedChannel {
|
||||||
channelId: Snowflake;
|
channelId: Snowflake;
|
||||||
guildId: Snowflake;
|
guildId: Snowflake;
|
||||||
type: keyof typeof ChannelType;
|
type: keyof typeof ChannelTypes;
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3182,17 +3189,17 @@ export interface GuildChannelCreateOptions {
|
|||||||
permissionOverwrites?: OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>;
|
permissionOverwrites?: OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>;
|
||||||
topic?: string;
|
topic?: string;
|
||||||
type?: Exclude<
|
type?: Exclude<
|
||||||
keyof typeof ChannelType | ChannelType,
|
keyof typeof ChannelTypes | ChannelTypes,
|
||||||
| 'dm'
|
| 'DM'
|
||||||
| 'group'
|
| 'GROUP_DM'
|
||||||
| 'unknown'
|
| 'UNKNOWN'
|
||||||
| 'public_thread'
|
| 'GUILD_PUBLIC_THREAD'
|
||||||
| 'private_thread'
|
| 'GUILD_PRIVATE_THREAD'
|
||||||
| ChannelType.dm
|
| ChannelTypes.DM
|
||||||
| ChannelType.group
|
| ChannelTypes.GROUP_DM
|
||||||
| ChannelType.unknown
|
| ChannelTypes.UNKNOWN
|
||||||
| ChannelType.public_thread
|
| ChannelTypes.GUILD_PUBLIC_THREAD
|
||||||
| ChannelType.private_thread
|
| ChannelTypes.GUILD_PRIVATE_THREAD
|
||||||
>;
|
>;
|
||||||
nsfw?: boolean;
|
nsfw?: boolean;
|
||||||
parent?: ChannelResolvable;
|
parent?: ChannelResolvable;
|
||||||
@@ -3807,7 +3814,7 @@ export interface PartialDMChannel
|
|||||||
lastMessageId: undefined;
|
lastMessageId: undefined;
|
||||||
messages: MessageManager;
|
messages: MessageManager;
|
||||||
recipient: User | PartialUser;
|
recipient: User | PartialUser;
|
||||||
type: 'dm';
|
type: 'DM';
|
||||||
readonly typing: boolean;
|
readonly typing: boolean;
|
||||||
readonly typingCount: number;
|
readonly typingCount: number;
|
||||||
}
|
}
|
||||||
@@ -3816,7 +3823,7 @@ export interface PartialChannelData {
|
|||||||
id?: Snowflake | number;
|
id?: Snowflake | number;
|
||||||
name: string;
|
name: string;
|
||||||
topic?: string;
|
topic?: string;
|
||||||
type?: ChannelType;
|
type?: ChannelTypes;
|
||||||
parentId?: Snowflake | number;
|
parentId?: Snowflake | number;
|
||||||
permissionOverwrites?: PartialOverwriteData[];
|
permissionOverwrites?: PartialOverwriteData[];
|
||||||
}
|
}
|
||||||
@@ -4033,11 +4040,19 @@ export interface StageInstanceEditOptions {
|
|||||||
privacyLevel?: PrivacyLevel | number;
|
privacyLevel?: PrivacyLevel | number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type TextBasedChannelTypes =
|
||||||
|
| 'DM'
|
||||||
|
| 'GUILD_TEXT'
|
||||||
|
| 'GUILD_NEWS'
|
||||||
|
| 'GUILD_NEWS_THREAD'
|
||||||
|
| 'GUILD_PUBLIC_THREAD'
|
||||||
|
| 'GUILD_PRIVATE_THREAD';
|
||||||
|
|
||||||
export type ThreadAutoArchiveDuration = 60 | 1440 | 4320 | 10080;
|
export type ThreadAutoArchiveDuration = 60 | 1440 | 4320 | 10080;
|
||||||
|
|
||||||
export type ThreadChannelResolvable = ThreadChannel | Snowflake;
|
export type ThreadChannelResolvable = ThreadChannel | Snowflake;
|
||||||
|
|
||||||
export type ThreadChannelType = 'news_thread' | 'public_thread' | 'private_thread';
|
export type ThreadChannelTypes = 'GUILD_NEWS_THREAD' | 'GUILD_PUBLIC_THREAD' | 'GUILD_PRIVATE_THREAD';
|
||||||
|
|
||||||
export interface ThreadCreateOptions<AllowedThreadType> {
|
export interface ThreadCreateOptions<AllowedThreadType> {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -4085,6 +4100,8 @@ export interface Vanity {
|
|||||||
|
|
||||||
export type VerificationLevel = keyof typeof VerificationLevels;
|
export type VerificationLevel = keyof typeof VerificationLevels;
|
||||||
|
|
||||||
|
export type VoiceBasedChannelTypes = 'GUILD_VOICE' | 'GUILD_STAGE_VOICE';
|
||||||
|
|
||||||
export type WebhookClientOptions = Pick<
|
export type WebhookClientOptions = Pick<
|
||||||
ClientOptions,
|
ClientOptions,
|
||||||
'allowedMentions' | 'restTimeOffset' | 'restRequestTimeout' | 'retryLimit' | 'http'
|
'allowedMentions' | 'restTimeOffset' | 'restRequestTimeout' | 'retryLimit' | 'http'
|
||||||
|
|||||||
Reference in New Issue
Block a user