feat: Guild Forum channel
https://github.com/discordjs/discord.js/pull/8651
This commit is contained in:
45
src/util/ChannelFlags.js
Normal file
45
src/util/ChannelFlags.js
Normal file
@@ -0,0 +1,45 @@
|
||||
'use strict';
|
||||
|
||||
const BitField = require('./BitField');
|
||||
|
||||
/**
|
||||
* Data structure that makes it easy to interact with a {@link BaseChannel#flags} bitfield.
|
||||
* @extends {BitField}
|
||||
*/
|
||||
class ChannelFlags extends BitField {}
|
||||
|
||||
/**
|
||||
* Numeric guild channel flags. All available properties:
|
||||
* * `PINNED`
|
||||
* * `REQUIRE_TAG`
|
||||
* @type {Object}
|
||||
* @see {@link https://discord.com/developers/docs/resources/channel#channel-object-channel-flags}
|
||||
*/
|
||||
ChannelFlags.FLAGS = {
|
||||
PINNED: 1 << 1,
|
||||
REQUIRE_TAG: 1 << 4,
|
||||
};
|
||||
|
||||
/**
|
||||
* @name ChannelFlags
|
||||
* @kind constructor
|
||||
* @memberof ChannelFlags
|
||||
* @param {BitFieldResolvable} [bits=0] Bit(s) to read from
|
||||
*/
|
||||
|
||||
/**
|
||||
* Bitfield of the packed bits
|
||||
* @type {number}
|
||||
* @name ChannelFlags#bitfield
|
||||
*/
|
||||
|
||||
/**
|
||||
* Data that can be resolved to give a channel flag bitfield. This can be:
|
||||
* * A string (see {@link ChannelFlags.FLAGS})
|
||||
* * A channel flag
|
||||
* * An instance of ChannelFlags
|
||||
* * An Array of ChannelFlags
|
||||
* @typedef {string|number|ChannelFlags|ChannelFlagsResolvable[]} ChannelFlagsResolvable
|
||||
*/
|
||||
|
||||
module.exports = ChannelFlags;
|
@@ -1640,6 +1640,15 @@ exports.GuildScheduledEventEntityTypes = createEnum([null, 'STAGE_INSTANCE', 'VO
|
||||
*/
|
||||
exports.VideoQualityModes = createEnum([null, 'AUTO', 'FULL']);
|
||||
|
||||
/**
|
||||
* Sort {@link ForumChannel} posts by ?
|
||||
* * LATEST_ACTIVITY
|
||||
* * CREATION_DATE
|
||||
* @typedef {string} SortOrderType
|
||||
* @see {@link https://discord.com/developers/docs/resources/channel/#channel-object-sort-order-types}
|
||||
*/
|
||||
exports.SortOrderTypes = createEnum([null, 'LATEST_ACTIVITY', 'CREATION_DATE']);
|
||||
|
||||
exports._cleanupSymbol = Symbol('djsCleanup');
|
||||
|
||||
function keyMirror(arr) {
|
||||
|
@@ -606,6 +606,71 @@ class Util extends null {
|
||||
let defaultValue;
|
||||
return () => (defaultValue ??= cb());
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms an API guild forum tag to camel-cased guild forum tag.
|
||||
* @param {APIGuildForumTag} tag The tag to transform
|
||||
* @returns {GuildForumTag}
|
||||
* @ignore
|
||||
*/
|
||||
static transformAPIGuildForumTag(tag) {
|
||||
return {
|
||||
id: tag.id,
|
||||
name: tag.name,
|
||||
moderated: tag.moderated,
|
||||
emoji:
|
||||
tag.emoji_id ?? tag.emoji_name
|
||||
? {
|
||||
id: tag.emoji_id,
|
||||
name: tag.emoji_name,
|
||||
}
|
||||
: null,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a camel-cased guild forum tag to an API guild forum tag.
|
||||
* @param {GuildForumTag} tag The tag to transform
|
||||
* @returns {APIGuildForumTag}
|
||||
* @ignore
|
||||
*/
|
||||
static transformGuildForumTag(tag) {
|
||||
return {
|
||||
id: tag.id,
|
||||
name: tag.name,
|
||||
moderated: tag.moderated,
|
||||
emoji_id: tag.emoji?.id ?? null,
|
||||
emoji_name: tag.emoji?.name ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms an API guild forum default reaction object to a
|
||||
* camel-cased guild forum default reaction object.
|
||||
* @param {APIGuildForumDefaultReactionEmoji} defaultReaction The default reaction to transform
|
||||
* @returns {DefaultReactionEmoji}
|
||||
* @ignore
|
||||
*/
|
||||
static transformAPIGuildDefaultReaction(defaultReaction) {
|
||||
return {
|
||||
id: defaultReaction.emoji_id,
|
||||
name: defaultReaction.emoji_name,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a camel-cased guild forum default reaction object to an
|
||||
* API guild forum default reaction object.
|
||||
* @param {DefaultReactionEmoji} defaultReaction The default reaction to transform
|
||||
* @returns {APIGuildForumDefaultReactionEmoji}
|
||||
* @ignore
|
||||
*/
|
||||
static transformGuildDefaultReaction(defaultReaction) {
|
||||
return {
|
||||
emoji_id: defaultReaction.id,
|
||||
emoji_name: defaultReaction.name,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Util;
|
||||
|
Reference in New Issue
Block a user