mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
refactor: remove discord.js enums and use discord-api-types enums instead (#7077)
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const { ChannelType } = require('discord-api-types/v9');
|
||||
const Action = require('./Action');
|
||||
const { Channel } = require('../../structures/Channel');
|
||||
const { ChannelTypes } = require('../../util/Constants');
|
||||
|
||||
class ChannelUpdateAction extends Action {
|
||||
handle(data) {
|
||||
@@ -12,7 +12,7 @@ class ChannelUpdateAction extends Action {
|
||||
if (channel) {
|
||||
const old = channel._update(data);
|
||||
|
||||
if (ChannelTypes[channel.type] !== data.type) {
|
||||
if (ChannelType[channel.type] !== data.type) {
|
||||
const newChannel = Channel.create(this.client, data, channel.guild);
|
||||
for (const [id, message] of channel.messages.cache) newChannel.messages.cache.set(id, message);
|
||||
channel = newChannel;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const { InteractionType, ComponentType, ApplicationCommandType } = require('discord-api-types/v9');
|
||||
const Action = require('./Action');
|
||||
const AutocompleteInteraction = require('../../structures/AutocompleteInteraction');
|
||||
const ButtonInteraction = require('../../structures/ButtonInteraction');
|
||||
@@ -7,7 +8,7 @@ const ChatInputCommandInteraction = require('../../structures/ChatInputCommandIn
|
||||
const MessageContextMenuCommandInteraction = require('../../structures/MessageContextMenuCommandInteraction');
|
||||
const SelectMenuInteraction = require('../../structures/SelectMenuInteraction');
|
||||
const UserContextMenuCommandInteraction = require('../../structures/UserContextMenuCommandInteraction');
|
||||
const { Events, InteractionTypes, MessageComponentTypes, ApplicationCommandTypes } = require('../../util/Constants');
|
||||
const { Events } = require('../../util/Constants');
|
||||
|
||||
class InteractionCreateAction extends Action {
|
||||
handle(data) {
|
||||
@@ -16,18 +17,18 @@ class InteractionCreateAction extends Action {
|
||||
// Resolve and cache partial channels for Interaction#channel getter
|
||||
this.getChannel(data);
|
||||
|
||||
let InteractionType;
|
||||
let InteractionClass;
|
||||
switch (data.type) {
|
||||
case InteractionTypes.APPLICATION_COMMAND:
|
||||
case InteractionType.ApplicationCommand:
|
||||
switch (data.data.type) {
|
||||
case ApplicationCommandTypes.CHAT_INPUT:
|
||||
InteractionType = ChatInputCommandInteraction;
|
||||
case ApplicationCommandType.ChatInput:
|
||||
InteractionClass = ChatInputCommandInteraction;
|
||||
break;
|
||||
case ApplicationCommandTypes.USER:
|
||||
InteractionType = UserContextMenuCommandInteraction;
|
||||
case ApplicationCommandType.User:
|
||||
InteractionClass = UserContextMenuCommandInteraction;
|
||||
break;
|
||||
case ApplicationCommandTypes.MESSAGE:
|
||||
InteractionType = MessageContextMenuCommandInteraction;
|
||||
case ApplicationCommandType.Message:
|
||||
InteractionClass = MessageContextMenuCommandInteraction;
|
||||
break;
|
||||
default:
|
||||
client.emit(
|
||||
@@ -37,13 +38,13 @@ class InteractionCreateAction extends Action {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case InteractionTypes.MESSAGE_COMPONENT:
|
||||
case InteractionType.MessageComponent:
|
||||
switch (data.data.component_type) {
|
||||
case MessageComponentTypes.BUTTON:
|
||||
InteractionType = ButtonInteraction;
|
||||
case ComponentType.Button:
|
||||
InteractionClass = ButtonInteraction;
|
||||
break;
|
||||
case MessageComponentTypes.SELECT_MENU:
|
||||
InteractionType = SelectMenuInteraction;
|
||||
case ComponentType.SelectMenu:
|
||||
InteractionClass = SelectMenuInteraction;
|
||||
break;
|
||||
default:
|
||||
client.emit(
|
||||
@@ -53,15 +54,15 @@ class InteractionCreateAction extends Action {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case InteractionTypes.APPLICATION_COMMAND_AUTOCOMPLETE:
|
||||
InteractionType = AutocompleteInteraction;
|
||||
case InteractionType.ApplicationCommandAutocomplete:
|
||||
InteractionClass = AutocompleteInteraction;
|
||||
break;
|
||||
default:
|
||||
client.emit(Events.DEBUG, `[INTERACTION] Received interaction with unknown type: ${data.type}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const interaction = new InteractionType(client, data);
|
||||
const interaction = new InteractionClass(client, data);
|
||||
|
||||
/**
|
||||
* Emitted when an interaction is created.
|
||||
|
||||
@@ -155,3 +155,28 @@ exports.WelcomeChannel = require('./structures/WelcomeChannel');
|
||||
exports.WelcomeScreen = require('./structures/WelcomeScreen');
|
||||
|
||||
exports.WebSocket = require('./WebSocket');
|
||||
|
||||
// External
|
||||
exports.ActivityType = require('discord-api-types/v9').ActivityType;
|
||||
exports.ApplicationCommandType = require('discord-api-types/v9').ApplicationCommandOptionType;
|
||||
exports.ApplicationCommandOptionType = require('discord-api-types/v9').ApplicationCommandOptionType;
|
||||
exports.ApplicationCommandPermissionType = require('discord-api-types/v9').ApplicationCommandPermissionType;
|
||||
exports.ButtonStyle = require('discord-api-types/v9').ButtonStyle;
|
||||
exports.ChannelType = require('discord-api-types/v9').ChannelType;
|
||||
exports.ComponentType = require('discord-api-types/v9').ComponentType;
|
||||
exports.GuildMFALevel = require('discord-api-types/v9').GuildMFALevel;
|
||||
exports.GuildNSFWLevel = require('discord-api-types/v9').GuildNSFWLevel;
|
||||
exports.GuildPremiumTier = require('discord-api-types/v9').GuildPremiumTier;
|
||||
exports.GuildScheduledEventEntityType = require('discord-api-types/v9').GuildScheduledEventEntityType;
|
||||
exports.GuildScheduledEventPrivacyLevel = require('discord-api-types/v9').GuildScheduledEventPrivacyLevel;
|
||||
exports.GuildScheduledEventStatus = require('discord-api-types/v9').GuildScheduledEventStatus;
|
||||
exports.GuildVerificationLevel = require('discord-api-types/v9').GuildVerificationLevel;
|
||||
exports.InteractionType = require('discord-api-types/v9').InteractionType;
|
||||
exports.InteractionResponseType = require('discord-api-types/v9').InteractionResponseType;
|
||||
exports.InviteTargetType = require('discord-api-types/v9').InviteTargetType;
|
||||
exports.MessageType = require('discord-api-types/v9').MessageType;
|
||||
exports.RESTJSONErrorCodes = require('discord-api-types/v9').RESTJSONErrorCodes;
|
||||
exports.StageInstancePrivacyLevel = require('discord-api-types/v9').StageInstancePrivacyLevel;
|
||||
exports.StickerType = require('discord-api-types/v9').StickerType;
|
||||
exports.StickerFormatType = require('discord-api-types/v9').StickerFormatType;
|
||||
exports.WebhookType = require('discord-api-types/v9').WebhookType;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const { ApplicationCommandType } = require('discord-api-types/v9');
|
||||
const ApplicationCommandPermissionsManager = require('./ApplicationCommandPermissionsManager');
|
||||
const CachedManager = require('./CachedManager');
|
||||
const { TypeError } = require('../errors');
|
||||
const ApplicationCommand = require('../structures/ApplicationCommand');
|
||||
const { ApplicationCommandTypes } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Manages API methods for application commands and stores their cache.
|
||||
@@ -207,7 +207,7 @@ class ApplicationCommandManager extends CachedManager {
|
||||
return {
|
||||
name: command.name,
|
||||
description: command.description,
|
||||
type: typeof command.type === 'number' ? command.type : ApplicationCommandTypes[command.type],
|
||||
type: typeof command.type === 'number' ? command.type : ApplicationCommandType[command.type],
|
||||
options: command.options?.map(o => ApplicationCommand.transformOption(o)),
|
||||
default_permission: command.defaultPermission ?? command.default_permission,
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const { ApplicationCommandPermissionType, RESTJSONErrorCodes } = require('discord-api-types/v9');
|
||||
const BaseManager = require('./BaseManager');
|
||||
const { Error, TypeError } = require('../errors');
|
||||
const { ApplicationCommandPermissionTypes, APIErrors } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Manages API methods for permissions of Application Commands.
|
||||
@@ -230,7 +230,7 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
||||
try {
|
||||
existing = await this.fetch({ guild: guildId, command: commandId });
|
||||
} catch (error) {
|
||||
if (error.code !== APIErrors.UNKNOWN_APPLICATION_COMMAND_PERMISSIONS) throw error;
|
||||
if (error.code !== RESTJSONErrorCodes.UnknownApplicationCommandPermissions) throw error;
|
||||
}
|
||||
|
||||
const newPermissions = permissions.slice();
|
||||
@@ -319,7 +319,7 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
||||
try {
|
||||
existing = await this.fetch({ guild: guildId, command: commandId });
|
||||
} catch (error) {
|
||||
if (error.code !== APIErrors.UNKNOWN_APPLICATION_COMMAND_PERMISSIONS) throw error;
|
||||
if (error.code !== RESTJSONErrorCodes.UnknownApplicationCommandPermissions) throw error;
|
||||
}
|
||||
|
||||
const permissions = existing.filter(perm => !resolvedIds.includes(perm.id));
|
||||
@@ -366,7 +366,7 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
||||
try {
|
||||
existing = await this.fetch({ guild: guildId, command: commandId });
|
||||
} catch (error) {
|
||||
if (error.code !== APIErrors.UNKNOWN_APPLICATION_COMMAND_PERMISSIONS) throw error;
|
||||
if (error.code !== RESTJSONErrorCodes.UnknownApplicationCommandPermissions) throw error;
|
||||
}
|
||||
|
||||
return existing.some(perm => perm.id === resolvedId);
|
||||
@@ -403,7 +403,7 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
||||
type:
|
||||
typeof permissions.type === 'number' && !received
|
||||
? permissions.type
|
||||
: ApplicationCommandPermissionTypes[permissions.type],
|
||||
: ApplicationCommandPermissionType[permissions.type],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
const process = require('node:process');
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const { ChannelType } = require('discord-api-types/v9');
|
||||
const CachedManager = require('./CachedManager');
|
||||
const ThreadManager = require('./ThreadManager');
|
||||
const { Error } = require('../errors');
|
||||
const GuildChannel = require('../structures/GuildChannel');
|
||||
const PermissionOverwrites = require('../structures/PermissionOverwrites');
|
||||
const ThreadChannel = require('../structures/ThreadChannel');
|
||||
const { ChannelTypes, ThreadChannelTypes } = require('../util/Constants');
|
||||
const { ThreadChannelTypes } = require('../util/Constants');
|
||||
|
||||
let cacheWarningEmitted = false;
|
||||
let storeChannelDeprecationEmitted = false;
|
||||
@@ -139,9 +140,9 @@ class GuildChannelManager extends CachedManager {
|
||||
) {
|
||||
parent &&= this.client.channels.resolveId(parent);
|
||||
permissionOverwrites &&= permissionOverwrites.map(o => PermissionOverwrites.resolve(o, this.guild));
|
||||
const intType = typeof type === 'number' ? type : ChannelTypes[type] ?? ChannelTypes.GUILD_TEXT;
|
||||
const intType = typeof type === 'number' ? type : ChannelType[type] ?? ChannelType.GuildText;
|
||||
|
||||
if (intType === ChannelTypes.GUILD_STORE && !storeChannelDeprecationEmitted) {
|
||||
if (intType === ChannelType.GuildStore && !storeChannelDeprecationEmitted) {
|
||||
storeChannelDeprecationEmitted = true;
|
||||
process.emitWarning(
|
||||
// eslint-disable-next-line max-len
|
||||
|
||||
@@ -3,6 +3,13 @@
|
||||
const process = require('node:process');
|
||||
const { setTimeout } = require('node:timers');
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const {
|
||||
GuildVerificationLevel,
|
||||
GuildDefaultMessageNotifications,
|
||||
GuildExplicitContentFilter,
|
||||
ChannelType,
|
||||
OverwriteType,
|
||||
} = require('discord-api-types/v9');
|
||||
const CachedManager = require('./CachedManager');
|
||||
const { Guild } = require('../structures/Guild');
|
||||
const GuildChannel = require('../structures/GuildChannel');
|
||||
@@ -11,14 +18,7 @@ const { GuildMember } = require('../structures/GuildMember');
|
||||
const Invite = require('../structures/Invite');
|
||||
const OAuth2Guild = require('../structures/OAuth2Guild');
|
||||
const { Role } = require('../structures/Role');
|
||||
const {
|
||||
ChannelTypes,
|
||||
Events,
|
||||
OverwriteTypes,
|
||||
VerificationLevels,
|
||||
DefaultMessageNotificationLevels,
|
||||
ExplicitContentFilterLevels,
|
||||
} = require('../util/Constants');
|
||||
const { Events } = require('../util/Constants');
|
||||
const DataResolver = require('../util/DataResolver');
|
||||
const Permissions = require('../util/Permissions');
|
||||
const SystemChannelFlags = require('../util/SystemChannelFlags');
|
||||
@@ -182,16 +182,16 @@ class GuildManager extends CachedManager {
|
||||
) {
|
||||
icon = await DataResolver.resolveImage(icon);
|
||||
if (typeof verificationLevel === 'string') {
|
||||
verificationLevel = VerificationLevels[verificationLevel];
|
||||
verificationLevel = GuildVerificationLevel[verificationLevel];
|
||||
}
|
||||
if (typeof defaultMessageNotifications === 'string') {
|
||||
defaultMessageNotifications = DefaultMessageNotificationLevels[defaultMessageNotifications];
|
||||
defaultMessageNotifications = GuildDefaultMessageNotifications[defaultMessageNotifications];
|
||||
}
|
||||
if (typeof explicitContentFilter === 'string') {
|
||||
explicitContentFilter = ExplicitContentFilterLevels[explicitContentFilter];
|
||||
explicitContentFilter = GuildExplicitContentFilter[explicitContentFilter];
|
||||
}
|
||||
for (const channel of channels) {
|
||||
channel.type &&= typeof channel.type === 'number' ? channel.type : ChannelTypes[channel.type];
|
||||
channel.type &&= typeof channel.type === 'number' ? channel.type : ChannelType[channel.type];
|
||||
channel.parent_id = channel.parentId;
|
||||
delete channel.parentId;
|
||||
channel.user_limit = channel.userLimit;
|
||||
@@ -204,7 +204,7 @@ class GuildManager extends CachedManager {
|
||||
if (!channel.permissionOverwrites) continue;
|
||||
for (const overwrite of channel.permissionOverwrites) {
|
||||
if (typeof overwrite.type === 'string') {
|
||||
overwrite.type = OverwriteTypes[overwrite.type];
|
||||
overwrite.type = OverwriteType[overwrite.type];
|
||||
}
|
||||
overwrite.allow &&= Permissions.resolve(overwrite.allow).toString();
|
||||
overwrite.deny &&= Permissions.resolve(overwrite.deny).toString();
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const {
|
||||
GuildScheduledEventPrivacyLevel,
|
||||
GuildScheduledEventEntityType,
|
||||
GuildScheduledEventStatus,
|
||||
} = require('discord-api-types/v9');
|
||||
const CachedManager = require('./CachedManager');
|
||||
const { TypeError, Error } = require('../errors');
|
||||
const { GuildScheduledEvent } = require('../structures/GuildScheduledEvent');
|
||||
const { PrivacyLevels, GuildScheduledEventEntityTypes, GuildScheduledEventStatuses } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Manages API methods for GuildScheduledEvents and stores their cache.
|
||||
@@ -78,11 +82,11 @@ class GuildScheduledEventManager extends CachedManager {
|
||||
reason,
|
||||
} = options;
|
||||
|
||||
if (typeof privacyLevel === 'string') privacyLevel = PrivacyLevels[privacyLevel];
|
||||
if (typeof entityType === 'string') entityType = GuildScheduledEventEntityTypes[entityType];
|
||||
if (typeof privacyLevel === 'string') privacyLevel = GuildScheduledEventPrivacyLevel[privacyLevel];
|
||||
if (typeof entityType === 'string') entityType = GuildScheduledEventEntityType[entityType];
|
||||
|
||||
let entity_metadata, channel_id;
|
||||
if (entityType === GuildScheduledEventEntityTypes.EXTERNAL) {
|
||||
if (entityType === GuildScheduledEventEntityType.External) {
|
||||
channel_id = typeof channel === 'undefined' ? channel : null;
|
||||
entity_metadata = { location: entityMetadata?.location };
|
||||
} else {
|
||||
@@ -199,9 +203,9 @@ class GuildScheduledEventManager extends CachedManager {
|
||||
reason,
|
||||
} = options;
|
||||
|
||||
if (typeof privacyLevel === 'string') privacyLevel = PrivacyLevels[privacyLevel];
|
||||
if (typeof entityType === 'string') entityType = GuildScheduledEventEntityTypes[entityType];
|
||||
if (typeof status === 'string') status = GuildScheduledEventStatuses[status];
|
||||
if (typeof privacyLevel === 'string') privacyLevel = GuildScheduledEventPrivacyLevel[privacyLevel];
|
||||
if (typeof entityType === 'string') entityType = GuildScheduledEventEntityType[entityType];
|
||||
if (typeof status === 'string') status = GuildScheduledEventStatus[status];
|
||||
|
||||
let entity_metadata;
|
||||
if (entityMetadata) {
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
const process = require('node:process');
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const { OverwriteType } = require('discord-api-types/v9');
|
||||
const CachedManager = require('./CachedManager');
|
||||
const { TypeError } = require('../errors');
|
||||
const PermissionOverwrites = require('../structures/PermissionOverwrites');
|
||||
const { Role } = require('../structures/Role');
|
||||
const { OverwriteTypes } = require('../util/Constants');
|
||||
|
||||
let cacheWarningEmitted = false;
|
||||
|
||||
@@ -94,7 +94,7 @@ class PermissionOverwriteManager extends CachedManager {
|
||||
if (typeof type !== 'number') {
|
||||
userOrRole = this.channel.guild.roles.resolve(userOrRole) ?? this.client.users.resolve(userOrRole);
|
||||
if (!userOrRole) throw new TypeError('INVALID_TYPE', 'parameter', 'User nor a Role');
|
||||
type = userOrRole instanceof Role ? OverwriteTypes.role : OverwriteTypes.member;
|
||||
type = userOrRole instanceof Role ? OverwriteType.Role : OverwriteType.Member;
|
||||
}
|
||||
|
||||
const { allow, deny } = PermissionOverwrites.resolveOverwriteOptions(options, existing);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const { GuildScheduledEventPrivacyLevel } = require('discord-api-types/v9');
|
||||
const CachedManager = require('./CachedManager');
|
||||
const { TypeError, Error } = require('../errors');
|
||||
const { StageInstance } = require('../structures/StageInstance');
|
||||
const { PrivacyLevels } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Manages API methods for {@link StageInstance} objects and holds their cache.
|
||||
@@ -60,7 +60,7 @@ class StageInstanceManager extends CachedManager {
|
||||
if (typeof options !== 'object') throw new TypeError('INVALID_TYPE', 'options', 'object', true);
|
||||
let { topic, privacyLevel } = options;
|
||||
|
||||
privacyLevel &&= typeof privacyLevel === 'number' ? privacyLevel : PrivacyLevels[privacyLevel];
|
||||
privacyLevel &&= typeof privacyLevel === 'number' ? privacyLevel : GuildScheduledEventPrivacyLevel[privacyLevel];
|
||||
|
||||
const data = await this.client.api['stage-instances'].post({
|
||||
data: {
|
||||
@@ -122,7 +122,7 @@ class StageInstanceManager extends CachedManager {
|
||||
|
||||
let { topic, privacyLevel } = options;
|
||||
|
||||
privacyLevel &&= typeof privacyLevel === 'number' ? privacyLevel : PrivacyLevels[privacyLevel];
|
||||
privacyLevel &&= typeof privacyLevel === 'number' ? privacyLevel : GuildScheduledEventPrivacyLevel[privacyLevel];
|
||||
|
||||
const data = await this.client.api('stage-instances', channelId).patch({
|
||||
data: {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const { ChannelType } = require('discord-api-types/v9');
|
||||
const CachedManager = require('./CachedManager');
|
||||
const { TypeError } = require('../errors');
|
||||
const ThreadChannel = require('../structures/ThreadChannel');
|
||||
const { ChannelTypes } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Manages API methods for {@link ThreadChannel} objects and stores their cache.
|
||||
@@ -111,14 +111,13 @@ class ThreadManager extends CachedManager {
|
||||
if (type && typeof type !== 'string' && typeof type !== 'number') {
|
||||
throw new TypeError('INVALID_TYPE', 'type', 'ThreadChannelType or Number');
|
||||
}
|
||||
let resolvedType =
|
||||
this.channel.type === 'GUILD_NEWS' ? ChannelTypes.GUILD_NEWS_THREAD : ChannelTypes.GUILD_PUBLIC_THREAD;
|
||||
let resolvedType = this.channel.type === 'GUILD_NEWS' ? ChannelType.GuildNewsThread : ChannelType.GuildPublicThread;
|
||||
if (startMessage) {
|
||||
const startMessageId = this.channel.messages.resolveId(startMessage);
|
||||
if (!startMessageId) throw new TypeError('INVALID_TYPE', 'startMessage', 'MessageResolvable');
|
||||
path = path.messages(startMessageId);
|
||||
} else if (this.channel.type !== 'GUILD_NEWS') {
|
||||
resolvedType = typeof type === 'string' ? ChannelTypes[type] : type ?? resolvedType;
|
||||
resolvedType = typeof type === 'string' ? ChannelType[type] : type ?? resolvedType;
|
||||
}
|
||||
if (autoArchiveDuration === 'MAX') {
|
||||
autoArchiveDuration = 1440;
|
||||
@@ -134,7 +133,7 @@ class ThreadManager extends CachedManager {
|
||||
name,
|
||||
auto_archive_duration: autoArchiveDuration,
|
||||
type: resolvedType,
|
||||
invitable: resolvedType === ChannelTypes.GUILD_PRIVATE_THREAD ? invitable : undefined,
|
||||
invitable: resolvedType === ChannelType.GuildPrivateThread ? invitable : undefined,
|
||||
rate_limit_per_user: rateLimitPerUser,
|
||||
},
|
||||
reason,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { GuildVerificationLevel, GuildNSFWLevel } = require('discord-api-types/v9');
|
||||
const BaseGuild = require('./BaseGuild');
|
||||
const { VerificationLevels, NSFWLevels } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Bundles common attributes and methods between {@link Guild} and {@link InviteGuild}
|
||||
@@ -46,7 +46,7 @@ class AnonymousGuild extends BaseGuild {
|
||||
* The verification level of the guild
|
||||
* @type {VerificationLevel}
|
||||
*/
|
||||
this.verificationLevel = VerificationLevels[data.verification_level];
|
||||
this.verificationLevel = GuildVerificationLevel[data.verification_level];
|
||||
}
|
||||
|
||||
if ('vanity_url_code' in data) {
|
||||
@@ -62,7 +62,7 @@ class AnonymousGuild extends BaseGuild {
|
||||
* The NSFW level of this guild
|
||||
* @type {NSFWLevel}
|
||||
*/
|
||||
this.nsfwLevel = NSFWLevels[data.nsfw_level];
|
||||
this.nsfwLevel = GuildNSFWLevel[data.nsfw_level];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||
const { ApplicationCommandType, ApplicationCommandOptionType, ChannelType } = require('discord-api-types/v9');
|
||||
const Base = require('./Base');
|
||||
const ApplicationCommandPermissionsManager = require('../managers/ApplicationCommandPermissionsManager');
|
||||
const { ApplicationCommandOptionTypes, ApplicationCommandTypes, ChannelTypes } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Represents an application command.
|
||||
@@ -48,7 +48,7 @@ class ApplicationCommand extends Base {
|
||||
* The type of this application command
|
||||
* @type {ApplicationCommandType}
|
||||
*/
|
||||
this.type = ApplicationCommandTypes[data.type];
|
||||
this.type = ApplicationCommandType[data.type];
|
||||
|
||||
this._patch(data);
|
||||
}
|
||||
@@ -233,7 +233,7 @@ class ApplicationCommand extends Base {
|
||||
if (command.id && this.id !== command.id) return false;
|
||||
|
||||
// Check top level parameters
|
||||
const commandType = typeof command.type === 'string' ? command.type : ApplicationCommandTypes[command.type];
|
||||
const commandType = typeof command.type === 'string' ? command.type : ApplicationCommandType[command.type];
|
||||
if (
|
||||
command.name !== this.name ||
|
||||
('description' in command && command.description !== this.description) ||
|
||||
@@ -289,7 +289,7 @@ class ApplicationCommand extends Base {
|
||||
* @private
|
||||
*/
|
||||
static _optionEquals(existing, option, enforceOptionOrder = false) {
|
||||
const optionType = typeof option.type === 'string' ? option.type : ApplicationCommandOptionTypes[option.type];
|
||||
const optionType = typeof option.type === 'string' ? option.type : ApplicationCommandOptionType[option.type];
|
||||
if (
|
||||
option.name !== existing.name ||
|
||||
optionType !== existing.type ||
|
||||
@@ -326,7 +326,7 @@ class ApplicationCommand extends Base {
|
||||
|
||||
if (existing.channelTypes) {
|
||||
const newTypes = (option.channelTypes ?? option.channel_types).map(type =>
|
||||
typeof type === 'number' ? ChannelTypes[type] : type,
|
||||
typeof type === 'number' ? ChannelType[type] : type,
|
||||
);
|
||||
for (const type of existing.channelTypes) {
|
||||
if (!newTypes.includes(type)) return false;
|
||||
@@ -370,12 +370,12 @@ class ApplicationCommand extends Base {
|
||||
* @private
|
||||
*/
|
||||
static transformOption(option, received) {
|
||||
const stringType = typeof option.type === 'string' ? option.type : ApplicationCommandOptionTypes[option.type];
|
||||
const stringType = typeof option.type === 'string' ? option.type : ApplicationCommandOptionType[option.type];
|
||||
const channelTypesKey = received ? 'channelTypes' : 'channel_types';
|
||||
const minValueKey = received ? 'minValue' : 'min_value';
|
||||
const maxValueKey = received ? 'maxValue' : 'max_value';
|
||||
return {
|
||||
type: typeof option.type === 'number' && !received ? option.type : ApplicationCommandOptionTypes[option.type],
|
||||
type: typeof option.type === 'number' && !received ? option.type : ApplicationCommandOptionType[option.type],
|
||||
name: option.name,
|
||||
description: option.description,
|
||||
required:
|
||||
@@ -384,8 +384,8 @@ class ApplicationCommand extends Base {
|
||||
choices: option.choices,
|
||||
options: option.options?.map(o => this.transformOption(o, received)),
|
||||
[channelTypesKey]: received
|
||||
? option.channel_types?.map(type => ChannelTypes[type])
|
||||
: option.channelTypes?.map(type => (typeof type === 'string' ? ChannelTypes[type] : type)) ??
|
||||
? option.channel_types?.map(type => ChannelType[type])
|
||||
: option.channelTypes?.map(type => (typeof type === 'string' ? ChannelType[type] : type)) ??
|
||||
// When transforming to API data, accept API data
|
||||
option.channel_types,
|
||||
[minValueKey]: option.minValue ?? option.min_value,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const { ApplicationCommandOptionType, InteractionResponseType } = require('discord-api-types/v9');
|
||||
const CommandInteractionOptionResolver = require('./CommandInteractionOptionResolver');
|
||||
const Interaction = require('./Interaction');
|
||||
const { InteractionResponseTypes, ApplicationCommandOptionTypes } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Represents an autocomplete interaction.
|
||||
@@ -64,7 +64,7 @@ class AutocompleteInteraction extends Interaction {
|
||||
transformOption(option) {
|
||||
const result = {
|
||||
name: option.name,
|
||||
type: ApplicationCommandOptionTypes[option.type],
|
||||
type: ApplicationCommandOptionType[option.type],
|
||||
};
|
||||
|
||||
if ('value' in option) result.value = option.value;
|
||||
@@ -94,7 +94,7 @@ class AutocompleteInteraction extends Interaction {
|
||||
|
||||
await this.client.api.interactions(this.id, this.token).callback.post({
|
||||
data: {
|
||||
type: InteractionResponseTypes.APPLICATION_COMMAND_AUTOCOMPLETE_RESULT,
|
||||
type: InteractionResponseType.ApplicationCommandAutocompleteResult,
|
||||
data: {
|
||||
choices: options,
|
||||
},
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||
const { ChannelType } = require('discord-api-types/v9');
|
||||
const Base = require('./Base');
|
||||
let CategoryChannel;
|
||||
let DMChannel;
|
||||
@@ -10,7 +11,7 @@ let StoreChannel;
|
||||
let TextChannel;
|
||||
let ThreadChannel;
|
||||
let VoiceChannel;
|
||||
const { ChannelTypes, ThreadChannelTypes, VoiceBasedChannelTypes } = require('../util/Constants');
|
||||
const { ThreadChannelTypes, VoiceBasedChannelTypes } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Represents any channel on Discord.
|
||||
@@ -21,7 +22,7 @@ class Channel extends Base {
|
||||
constructor(client, data, immediatePatch = true) {
|
||||
super(client);
|
||||
|
||||
const type = ChannelTypes[data?.type];
|
||||
const type = ChannelType[data?.type];
|
||||
/**
|
||||
* The type of the channel
|
||||
* @type {ChannelType}
|
||||
@@ -137,9 +138,9 @@ class Channel extends Base {
|
||||
|
||||
let channel;
|
||||
if (!data.guild_id && !guild) {
|
||||
if ((data.recipients && data.type !== ChannelTypes.GROUP_DM) || data.type === ChannelTypes.DM) {
|
||||
if ((data.recipients && data.type !== ChannelType.GroupDM) || data.type === ChannelType.DM) {
|
||||
channel = new DMChannel(client, data);
|
||||
} else if (data.type === ChannelTypes.GROUP_DM) {
|
||||
} else if (data.type === ChannelType.GroupDM) {
|
||||
const PartialGroupDMChannel = require('./PartialGroupDMChannel');
|
||||
channel = new PartialGroupDMChannel(client, data);
|
||||
}
|
||||
@@ -148,33 +149,33 @@ class Channel extends Base {
|
||||
|
||||
if (guild || allowUnknownGuild) {
|
||||
switch (data.type) {
|
||||
case ChannelTypes.GUILD_TEXT: {
|
||||
case ChannelType.GuildText: {
|
||||
channel = new TextChannel(guild, data, client);
|
||||
break;
|
||||
}
|
||||
case ChannelTypes.GUILD_VOICE: {
|
||||
case ChannelType.GuildVoice: {
|
||||
channel = new VoiceChannel(guild, data, client);
|
||||
break;
|
||||
}
|
||||
case ChannelTypes.GUILD_CATEGORY: {
|
||||
case ChannelType.GuildCategory: {
|
||||
channel = new CategoryChannel(guild, data, client);
|
||||
break;
|
||||
}
|
||||
case ChannelTypes.GUILD_NEWS: {
|
||||
case ChannelType.GuildNews: {
|
||||
channel = new NewsChannel(guild, data, client);
|
||||
break;
|
||||
}
|
||||
case ChannelTypes.GUILD_STORE: {
|
||||
case ChannelType.GuildStore: {
|
||||
channel = new StoreChannel(guild, data, client);
|
||||
break;
|
||||
}
|
||||
case ChannelTypes.GUILD_STAGE_VOICE: {
|
||||
case ChannelType.GuildStageVoice: {
|
||||
channel = new StageChannel(guild, data, client);
|
||||
break;
|
||||
}
|
||||
case ChannelTypes.GUILD_NEWS_THREAD:
|
||||
case ChannelTypes.GUILD_PUBLIC_THREAD:
|
||||
case ChannelTypes.GUILD_PRIVATE_THREAD: {
|
||||
case ChannelType.GuildNewsThread:
|
||||
case ChannelType.GuildPublicThread:
|
||||
case ChannelType.GuildPrivateThread: {
|
||||
channel = new ThreadChannel(guild, data, client, fromInteraction);
|
||||
if (!allowUnknownGuild) channel.parent?.threads.cache.set(channel.id, channel);
|
||||
break;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const { ActivityType } = require('discord-api-types/v9');
|
||||
const { Presence } = require('./Presence');
|
||||
const { TypeError } = require('../errors');
|
||||
const { ActivityTypes, Opcodes } = require('../util/Constants');
|
||||
const { Opcodes } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Represents the client's presence.
|
||||
@@ -52,7 +53,7 @@ class ClientPresence extends Presence {
|
||||
activity.type ??= 0;
|
||||
|
||||
data.activities.push({
|
||||
type: typeof activity.type === 'number' ? activity.type : ActivityTypes[activity.type],
|
||||
type: typeof activity.type === 'number' ? activity.type : ActivityType[activity.type],
|
||||
name: activity.name,
|
||||
url: activity.url,
|
||||
});
|
||||
@@ -61,7 +62,7 @@ class ClientPresence extends Presence {
|
||||
data.activities.push(
|
||||
...this.activities.map(a => ({
|
||||
name: a.name,
|
||||
type: ActivityTypes[a.type],
|
||||
type: ActivityType[a.type],
|
||||
url: a.url ?? undefined,
|
||||
})),
|
||||
);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const { ApplicationCommandType } = require('discord-api-types/v9');
|
||||
const Interaction = require('./Interaction');
|
||||
const InteractionWebhook = require('./InteractionWebhook');
|
||||
const InteractionResponses = require('./interfaces/InteractionResponses');
|
||||
const { ApplicationCommandOptionTypes } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Represents a command interaction.
|
||||
@@ -151,7 +151,7 @@ class CommandInteraction extends Interaction {
|
||||
transformOption(option, resolved) {
|
||||
const result = {
|
||||
name: option.name,
|
||||
type: ApplicationCommandOptionTypes[option.type],
|
||||
type: ApplicationCommandType[option.type],
|
||||
};
|
||||
|
||||
if ('value' in option) result.value = option.value;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const { ApplicationCommandType } = require('discord-api-types/v9');
|
||||
const CommandInteraction = require('./CommandInteraction');
|
||||
const CommandInteractionOptionResolver = require('./CommandInteractionOptionResolver');
|
||||
const { ApplicationCommandOptionTypes, ApplicationCommandTypes } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Represents a context menu interaction.
|
||||
@@ -31,7 +31,7 @@ class ContextMenuCommandInteraction extends CommandInteraction {
|
||||
* The type of the target of the interaction; either USER or MESSAGE
|
||||
* @type {ApplicationCommandType}
|
||||
*/
|
||||
this.targetType = ApplicationCommandTypes[data.data.type];
|
||||
this.targetType = ApplicationCommandType[data.data.type];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,7 +45,7 @@ class ContextMenuCommandInteraction extends CommandInteraction {
|
||||
|
||||
if (resolved.users?.[target_id]) {
|
||||
result.push(
|
||||
this.transformOption({ name: 'user', type: ApplicationCommandOptionTypes.USER, value: target_id }, resolved),
|
||||
this.transformOption({ name: 'user', type: ApplicationCommandType.User, value: target_id }, resolved),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const {
|
||||
GuildPremiumTier,
|
||||
GuildMFALevel,
|
||||
GuildExplicitContentFilter,
|
||||
GuildDefaultMessageNotifications,
|
||||
GuildVerificationLevel,
|
||||
ChannelType,
|
||||
} = require('discord-api-types/v9');
|
||||
const AnonymousGuild = require('./AnonymousGuild');
|
||||
const GuildAuditLogs = require('./GuildAuditLogs');
|
||||
const GuildPreview = require('./GuildPreview');
|
||||
@@ -21,16 +29,7 @@ const PresenceManager = require('../managers/PresenceManager');
|
||||
const RoleManager = require('../managers/RoleManager');
|
||||
const StageInstanceManager = require('../managers/StageInstanceManager');
|
||||
const VoiceStateManager = require('../managers/VoiceStateManager');
|
||||
const {
|
||||
ChannelTypes,
|
||||
DefaultMessageNotificationLevels,
|
||||
PartialTypes,
|
||||
VerificationLevels,
|
||||
ExplicitContentFilterLevels,
|
||||
Status,
|
||||
MFALevels,
|
||||
PremiumTiers,
|
||||
} = require('../util/Constants');
|
||||
const { PartialTypes, Status } = require('../util/Constants');
|
||||
const DataResolver = require('../util/DataResolver');
|
||||
const SystemChannelFlags = require('../util/SystemChannelFlags');
|
||||
const Util = require('../util/Util');
|
||||
@@ -241,7 +240,7 @@ class Guild extends AnonymousGuild {
|
||||
* The premium tier of this guild
|
||||
* @type {PremiumTier}
|
||||
*/
|
||||
this.premiumTier = PremiumTiers[data.premium_tier];
|
||||
this.premiumTier = GuildPremiumTier[data.premium_tier];
|
||||
}
|
||||
|
||||
if ('premium_subscription_count' in data) {
|
||||
@@ -273,7 +272,7 @@ class Guild extends AnonymousGuild {
|
||||
* The explicit content filter level of the guild
|
||||
* @type {ExplicitContentFilterLevel}
|
||||
*/
|
||||
this.explicitContentFilter = ExplicitContentFilterLevels[data.explicit_content_filter];
|
||||
this.explicitContentFilter = GuildExplicitContentFilter[data.explicit_content_filter];
|
||||
}
|
||||
|
||||
if ('mfa_level' in data) {
|
||||
@@ -281,7 +280,7 @@ class Guild extends AnonymousGuild {
|
||||
* The required MFA level for this guild
|
||||
* @type {MFALevel}
|
||||
*/
|
||||
this.mfaLevel = MFALevels[data.mfa_level];
|
||||
this.mfaLevel = GuildMFALevel[data.mfa_level];
|
||||
}
|
||||
|
||||
if ('joined_at' in data) {
|
||||
@@ -295,9 +294,9 @@ class Guild extends AnonymousGuild {
|
||||
if ('default_message_notifications' in data) {
|
||||
/**
|
||||
* The default message notification level of the guild
|
||||
* @type {DefaultMessageNotificationLevel}
|
||||
* @type {GuildDefaultMessageNotifications}
|
||||
*/
|
||||
this.defaultMessageNotifications = DefaultMessageNotificationLevels[data.default_message_notifications];
|
||||
this.defaultMessageNotifications = GuildDefaultMessageNotifications[data.default_message_notifications];
|
||||
}
|
||||
|
||||
if ('system_channel_flags' in data) {
|
||||
@@ -567,12 +566,12 @@ class Guild extends AnonymousGuild {
|
||||
return 384_000;
|
||||
}
|
||||
|
||||
switch (PremiumTiers[this.premiumTier]) {
|
||||
case PremiumTiers.TIER_1:
|
||||
switch (GuildPremiumTier[this.premiumTier]) {
|
||||
case GuildPremiumTier.Tier1:
|
||||
return 128_000;
|
||||
case PremiumTiers.TIER_2:
|
||||
case GuildPremiumTier.Tier2:
|
||||
return 256_000;
|
||||
case PremiumTiers.TIER_3:
|
||||
case GuildPremiumTier.Tier3:
|
||||
return 384_000;
|
||||
default:
|
||||
return 96_000;
|
||||
@@ -821,7 +820,7 @@ class Guild extends AnonymousGuild {
|
||||
_data.verification_level =
|
||||
typeof data.verificationLevel === 'number'
|
||||
? data.verificationLevel
|
||||
: VerificationLevels[data.verificationLevel];
|
||||
: GuildVerificationLevel[data.verificationLevel];
|
||||
}
|
||||
if (typeof data.afkChannel !== 'undefined') {
|
||||
_data.afk_channel_id = this.client.channels.resolveId(data.afkChannel);
|
||||
@@ -841,13 +840,13 @@ class Guild extends AnonymousGuild {
|
||||
_data.explicit_content_filter =
|
||||
typeof data.explicitContentFilter === 'number'
|
||||
? data.explicitContentFilter
|
||||
: ExplicitContentFilterLevels[data.explicitContentFilter];
|
||||
: GuildExplicitContentFilter[data.explicitContentFilter];
|
||||
}
|
||||
if (typeof data.defaultMessageNotifications !== 'undefined') {
|
||||
_data.default_message_notifications =
|
||||
typeof data.defaultMessageNotifications === 'number'
|
||||
? data.defaultMessageNotifications
|
||||
: DefaultMessageNotificationLevels[data.defaultMessageNotifications];
|
||||
: GuildDefaultMessageNotifications[data.defaultMessageNotifications];
|
||||
}
|
||||
if (typeof data.systemChannelFlags !== 'undefined') {
|
||||
_data.system_channel_flags = SystemChannelFlags.resolve(data.systemChannelFlags);
|
||||
@@ -1303,7 +1302,7 @@ class Guild extends AnonymousGuild {
|
||||
* @private
|
||||
*/
|
||||
_sortedChannels(channel) {
|
||||
const category = channel.type === ChannelTypes.GUILD_CATEGORY;
|
||||
const category = channel.type === ChannelType.GuildCategory;
|
||||
return Util.discordSort(
|
||||
this.channels.cache.filter(
|
||||
c =>
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||
const { OverwriteType, AuditLogEvent } = require('discord-api-types/v9');
|
||||
const { GuildScheduledEvent } = require('./GuildScheduledEvent');
|
||||
const Integration = require('./Integration');
|
||||
const Invite = require('./Invite');
|
||||
const { StageInstance } = require('./StageInstance');
|
||||
const { Sticker } = require('./Sticker');
|
||||
const Webhook = require('./Webhook');
|
||||
const { OverwriteTypes, PartialTypes } = require('../util/Constants');
|
||||
const { PartialTypes } = require('../util/Constants');
|
||||
const Util = require('../util/Util');
|
||||
|
||||
/**
|
||||
@@ -52,116 +53,6 @@ const Targets = {
|
||||
UNKNOWN: 'UNKNOWN',
|
||||
};
|
||||
|
||||
/**
|
||||
* The action of an entry. Here are the available actions:
|
||||
* * ALL: null
|
||||
* * GUILD_UPDATE: 1
|
||||
* * CHANNEL_CREATE: 10
|
||||
* * CHANNEL_UPDATE: 11
|
||||
* * CHANNEL_DELETE: 12
|
||||
* * CHANNEL_OVERWRITE_CREATE: 13
|
||||
* * CHANNEL_OVERWRITE_UPDATE: 14
|
||||
* * CHANNEL_OVERWRITE_DELETE: 15
|
||||
* * MEMBER_KICK: 20
|
||||
* * MEMBER_PRUNE: 21
|
||||
* * MEMBER_BAN_ADD: 22
|
||||
* * MEMBER_BAN_REMOVE: 23
|
||||
* * MEMBER_UPDATE: 24
|
||||
* * MEMBER_ROLE_UPDATE: 25
|
||||
* * MEMBER_MOVE: 26
|
||||
* * MEMBER_DISCONNECT: 27
|
||||
* * BOT_ADD: 28,
|
||||
* * ROLE_CREATE: 30
|
||||
* * ROLE_UPDATE: 31
|
||||
* * ROLE_DELETE: 32
|
||||
* * INVITE_CREATE: 40
|
||||
* * INVITE_UPDATE: 41
|
||||
* * INVITE_DELETE: 42
|
||||
* * WEBHOOK_CREATE: 50
|
||||
* * WEBHOOK_UPDATE: 51
|
||||
* * WEBHOOK_DELETE: 52
|
||||
* * EMOJI_CREATE: 60
|
||||
* * EMOJI_UPDATE: 61
|
||||
* * EMOJI_DELETE: 62
|
||||
* * MESSAGE_DELETE: 72
|
||||
* * MESSAGE_BULK_DELETE: 73
|
||||
* * MESSAGE_PIN: 74
|
||||
* * MESSAGE_UNPIN: 75
|
||||
* * INTEGRATION_CREATE: 80
|
||||
* * INTEGRATION_UPDATE: 81
|
||||
* * INTEGRATION_DELETE: 82
|
||||
* * STAGE_INSTANCE_CREATE: 83
|
||||
* * STAGE_INSTANCE_UPDATE: 84
|
||||
* * STAGE_INSTANCE_DELETE: 85
|
||||
* * STICKER_CREATE: 90
|
||||
* * STICKER_UPDATE: 91
|
||||
* * STICKER_DELETE: 92
|
||||
* * GUILD_SCHEDULED_EVENT_CREATE: 100
|
||||
* * GUILD_SCHEDULED_EVENT_UPDATE: 101
|
||||
* * GUILD_SCHEDULED_EVENT_DELETE: 102
|
||||
* * THREAD_CREATE: 110
|
||||
* * THREAD_UPDATE: 111
|
||||
* * THREAD_DELETE: 112
|
||||
* @typedef {?(number|string)} AuditLogAction
|
||||
* @see {@link https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events}
|
||||
*/
|
||||
|
||||
/**
|
||||
* All available actions keyed under their names to their numeric values.
|
||||
* @name GuildAuditLogs.Actions
|
||||
* @type {Object<string, number>}
|
||||
*/
|
||||
const Actions = {
|
||||
ALL: null,
|
||||
GUILD_UPDATE: 1,
|
||||
CHANNEL_CREATE: 10,
|
||||
CHANNEL_UPDATE: 11,
|
||||
CHANNEL_DELETE: 12,
|
||||
CHANNEL_OVERWRITE_CREATE: 13,
|
||||
CHANNEL_OVERWRITE_UPDATE: 14,
|
||||
CHANNEL_OVERWRITE_DELETE: 15,
|
||||
MEMBER_KICK: 20,
|
||||
MEMBER_PRUNE: 21,
|
||||
MEMBER_BAN_ADD: 22,
|
||||
MEMBER_BAN_REMOVE: 23,
|
||||
MEMBER_UPDATE: 24,
|
||||
MEMBER_ROLE_UPDATE: 25,
|
||||
MEMBER_MOVE: 26,
|
||||
MEMBER_DISCONNECT: 27,
|
||||
BOT_ADD: 28,
|
||||
ROLE_CREATE: 30,
|
||||
ROLE_UPDATE: 31,
|
||||
ROLE_DELETE: 32,
|
||||
INVITE_CREATE: 40,
|
||||
INVITE_UPDATE: 41,
|
||||
INVITE_DELETE: 42,
|
||||
WEBHOOK_CREATE: 50,
|
||||
WEBHOOK_UPDATE: 51,
|
||||
WEBHOOK_DELETE: 52,
|
||||
EMOJI_CREATE: 60,
|
||||
EMOJI_UPDATE: 61,
|
||||
EMOJI_DELETE: 62,
|
||||
MESSAGE_DELETE: 72,
|
||||
MESSAGE_BULK_DELETE: 73,
|
||||
MESSAGE_PIN: 74,
|
||||
MESSAGE_UNPIN: 75,
|
||||
INTEGRATION_CREATE: 80,
|
||||
INTEGRATION_UPDATE: 81,
|
||||
INTEGRATION_DELETE: 82,
|
||||
STAGE_INSTANCE_CREATE: 83,
|
||||
STAGE_INSTANCE_UPDATE: 84,
|
||||
STAGE_INSTANCE_DELETE: 85,
|
||||
STICKER_CREATE: 90,
|
||||
STICKER_UPDATE: 91,
|
||||
STICKER_DELETE: 92,
|
||||
GUILD_SCHEDULED_EVENT_CREATE: 100,
|
||||
GUILD_SCHEDULED_EVENT_UPDATE: 101,
|
||||
GUILD_SCHEDULED_EVENT_DELETE: 102,
|
||||
THREAD_CREATE: 110,
|
||||
THREAD_UPDATE: 111,
|
||||
THREAD_DELETE: 112,
|
||||
};
|
||||
|
||||
/**
|
||||
* Audit logs entries are held in this class.
|
||||
*/
|
||||
@@ -274,20 +165,20 @@ class GuildAuditLogs {
|
||||
static actionType(action) {
|
||||
if (
|
||||
[
|
||||
Actions.CHANNEL_CREATE,
|
||||
Actions.CHANNEL_OVERWRITE_CREATE,
|
||||
Actions.MEMBER_BAN_REMOVE,
|
||||
Actions.BOT_ADD,
|
||||
Actions.ROLE_CREATE,
|
||||
Actions.INVITE_CREATE,
|
||||
Actions.WEBHOOK_CREATE,
|
||||
Actions.EMOJI_CREATE,
|
||||
Actions.MESSAGE_PIN,
|
||||
Actions.INTEGRATION_CREATE,
|
||||
Actions.STAGE_INSTANCE_CREATE,
|
||||
Actions.STICKER_CREATE,
|
||||
Actions.GUILD_SCHEDULED_EVENT_CREATE,
|
||||
Actions.THREAD_CREATE,
|
||||
AuditLogEvent.ChannelCreate,
|
||||
AuditLogEvent.ChannelOverwriteCreate,
|
||||
AuditLogEvent.MemberBanRemove,
|
||||
AuditLogEvent.BotAdd,
|
||||
AuditLogEvent.RoleCreate,
|
||||
AuditLogEvent.InviteCreate,
|
||||
AuditLogEvent.WebhookCreate,
|
||||
AuditLogEvent.EmojiCreate,
|
||||
AuditLogEvent.MessagePin,
|
||||
AuditLogEvent.IntegrationCreate,
|
||||
AuditLogEvent.StageInstanceCreate,
|
||||
AuditLogEvent.StickerCreate,
|
||||
AuditLogEvent.GuildScheduledEventCreate,
|
||||
AuditLogEvent.ThreadCreate,
|
||||
].includes(action)
|
||||
) {
|
||||
return 'CREATE';
|
||||
@@ -295,24 +186,24 @@ class GuildAuditLogs {
|
||||
|
||||
if (
|
||||
[
|
||||
Actions.CHANNEL_DELETE,
|
||||
Actions.CHANNEL_OVERWRITE_DELETE,
|
||||
Actions.MEMBER_KICK,
|
||||
Actions.MEMBER_PRUNE,
|
||||
Actions.MEMBER_BAN_ADD,
|
||||
Actions.MEMBER_DISCONNECT,
|
||||
Actions.ROLE_DELETE,
|
||||
Actions.INVITE_DELETE,
|
||||
Actions.WEBHOOK_DELETE,
|
||||
Actions.EMOJI_DELETE,
|
||||
Actions.MESSAGE_DELETE,
|
||||
Actions.MESSAGE_BULK_DELETE,
|
||||
Actions.MESSAGE_UNPIN,
|
||||
Actions.INTEGRATION_DELETE,
|
||||
Actions.STAGE_INSTANCE_DELETE,
|
||||
Actions.STICKER_DELETE,
|
||||
Actions.GUILD_SCHEDULED_EVENT_DELETE,
|
||||
Actions.THREAD_DELETE,
|
||||
AuditLogEvent.ChannelDelete,
|
||||
AuditLogEvent.ChannelOverwriteDelete,
|
||||
AuditLogEvent.MemberKick,
|
||||
AuditLogEvent.MemberPrune,
|
||||
AuditLogEvent.MemberBanAdd,
|
||||
AuditLogEvent.MemberDisconnect,
|
||||
AuditLogEvent.RoleDelete,
|
||||
AuditLogEvent.InviteDelete,
|
||||
AuditLogEvent.WebhookDelete,
|
||||
AuditLogEvent.EmojiDelete,
|
||||
AuditLogEvent.MessageDelete,
|
||||
AuditLogEvent.MessageBulkDelete,
|
||||
AuditLogEvent.MessageUnpin,
|
||||
AuditLogEvent.IntegrationDelete,
|
||||
AuditLogEvent.StageInstanceDelete,
|
||||
AuditLogEvent.StickerDelete,
|
||||
AuditLogEvent.GuildScheduledEventDelete,
|
||||
AuditLogEvent.ThreadDelete,
|
||||
].includes(action)
|
||||
) {
|
||||
return 'DELETE';
|
||||
@@ -320,21 +211,21 @@ class GuildAuditLogs {
|
||||
|
||||
if (
|
||||
[
|
||||
Actions.GUILD_UPDATE,
|
||||
Actions.CHANNEL_UPDATE,
|
||||
Actions.CHANNEL_OVERWRITE_UPDATE,
|
||||
Actions.MEMBER_UPDATE,
|
||||
Actions.MEMBER_ROLE_UPDATE,
|
||||
Actions.MEMBER_MOVE,
|
||||
Actions.ROLE_UPDATE,
|
||||
Actions.INVITE_UPDATE,
|
||||
Actions.WEBHOOK_UPDATE,
|
||||
Actions.EMOJI_UPDATE,
|
||||
Actions.INTEGRATION_UPDATE,
|
||||
Actions.STAGE_INSTANCE_UPDATE,
|
||||
Actions.STICKER_UPDATE,
|
||||
Actions.GUILD_SCHEDULED_EVENT_UPDATE,
|
||||
Actions.THREAD_UPDATE,
|
||||
AuditLogEvent.GuildUpdate,
|
||||
AuditLogEvent.ChannelUpdate,
|
||||
AuditLogEvent.ChannelOverwriteUpdate,
|
||||
AuditLogEvent.MemberUpdate,
|
||||
AuditLogEvent.MemberRoleUpdate,
|
||||
AuditLogEvent.MemberMove,
|
||||
AuditLogEvent.RoleUpdate,
|
||||
AuditLogEvent.InviteUpdate,
|
||||
AuditLogEvent.WebhookUpdate,
|
||||
AuditLogEvent.EmojiUpdate,
|
||||
AuditLogEvent.IntegrationUpdate,
|
||||
AuditLogEvent.StageInstanceUpdate,
|
||||
AuditLogEvent.StickerUpdate,
|
||||
AuditLogEvent.GuildScheduledEventUpdate,
|
||||
AuditLogEvent.ThreadUpdate,
|
||||
].includes(action)
|
||||
) {
|
||||
return 'UPDATE';
|
||||
@@ -370,7 +261,7 @@ class GuildAuditLogsEntry {
|
||||
* Specific action type of this entry in its string presentation
|
||||
* @type {AuditLogAction}
|
||||
*/
|
||||
this.action = Object.keys(Actions).find(k => Actions[k] === data.action_type);
|
||||
this.action = Object.keys(AuditLogEvent).find(k => AuditLogEvent[k] === data.action_type);
|
||||
|
||||
/**
|
||||
* The reason of this entry
|
||||
@@ -414,52 +305,52 @@ class GuildAuditLogsEntry {
|
||||
*/
|
||||
this.extra = null;
|
||||
switch (data.action_type) {
|
||||
case Actions.MEMBER_PRUNE:
|
||||
case AuditLogEvent.MemberPrune:
|
||||
this.extra = {
|
||||
removed: Number(data.options.members_removed),
|
||||
days: Number(data.options.delete_member_days),
|
||||
};
|
||||
break;
|
||||
|
||||
case Actions.MEMBER_MOVE:
|
||||
case Actions.MESSAGE_DELETE:
|
||||
case Actions.MESSAGE_BULK_DELETE:
|
||||
case AuditLogEvent.MemberMove:
|
||||
case AuditLogEvent.MessageDelete:
|
||||
case AuditLogEvent.MessageBulkDelete:
|
||||
this.extra = {
|
||||
channel: guild.channels.cache.get(data.options.channel_id) ?? { id: data.options.channel_id },
|
||||
count: Number(data.options.count),
|
||||
};
|
||||
break;
|
||||
|
||||
case Actions.MESSAGE_PIN:
|
||||
case Actions.MESSAGE_UNPIN:
|
||||
case AuditLogEvent.MessagePin:
|
||||
case AuditLogEvent.MessageUnpin:
|
||||
this.extra = {
|
||||
channel: guild.client.channels.cache.get(data.options.channel_id) ?? { id: data.options.channel_id },
|
||||
messageId: data.options.message_id,
|
||||
};
|
||||
break;
|
||||
|
||||
case Actions.MEMBER_DISCONNECT:
|
||||
case AuditLogEvent.MemberDisconnect:
|
||||
this.extra = {
|
||||
count: Number(data.options.count),
|
||||
};
|
||||
break;
|
||||
|
||||
case Actions.CHANNEL_OVERWRITE_CREATE:
|
||||
case Actions.CHANNEL_OVERWRITE_UPDATE:
|
||||
case Actions.CHANNEL_OVERWRITE_DELETE:
|
||||
case AuditLogEvent.ChannelOverwriteCreate:
|
||||
case AuditLogEvent.ChannelOverwriteUpdate:
|
||||
case AuditLogEvent.ChannelOverwriteDelete:
|
||||
switch (Number(data.options.type)) {
|
||||
case OverwriteTypes.role:
|
||||
case OverwriteType.Role:
|
||||
this.extra = guild.roles.cache.get(data.options.id) ?? {
|
||||
id: data.options.id,
|
||||
name: data.options.role_name,
|
||||
type: OverwriteTypes[OverwriteTypes.role],
|
||||
type: OverwriteType[OverwriteType.Role],
|
||||
};
|
||||
break;
|
||||
|
||||
case OverwriteTypes.member:
|
||||
case OverwriteType.Member:
|
||||
this.extra = guild.members.cache.get(data.options.id) ?? {
|
||||
id: data.options.id,
|
||||
type: OverwriteTypes[OverwriteTypes.member],
|
||||
type: OverwriteType[OverwriteType.Member],
|
||||
};
|
||||
break;
|
||||
|
||||
@@ -468,9 +359,9 @@ class GuildAuditLogsEntry {
|
||||
}
|
||||
break;
|
||||
|
||||
case Actions.STAGE_INSTANCE_CREATE:
|
||||
case Actions.STAGE_INSTANCE_DELETE:
|
||||
case Actions.STAGE_INSTANCE_UPDATE:
|
||||
case AuditLogEvent.StageInstanceCreate:
|
||||
case AuditLogEvent.StageInstanceDelete:
|
||||
case AuditLogEvent.StageInstanceUpdate:
|
||||
this.extra = {
|
||||
channel: guild.client.channels.cache.get(data.options?.channel_id) ?? { id: data.options?.channel_id },
|
||||
};
|
||||
@@ -533,7 +424,7 @@ class GuildAuditLogsEntry {
|
||||
} else if (targetType === Targets.MESSAGE) {
|
||||
// Discord sends a channel id for the MESSAGE_BULK_DELETE action type.
|
||||
this.target =
|
||||
data.action_type === Actions.MESSAGE_BULK_DELETE
|
||||
data.action_type === AuditLogEvent.MessageBulkDelete
|
||||
? guild.channels.cache.get(data.target_id) ?? { id: data.target_id }
|
||||
: guild.client.users.cache.get(data.target_id);
|
||||
} else if (targetType === Targets.INTEGRATION) {
|
||||
@@ -631,7 +522,6 @@ class GuildAuditLogsEntry {
|
||||
}
|
||||
}
|
||||
|
||||
GuildAuditLogs.Actions = Actions;
|
||||
GuildAuditLogs.Targets = Targets;
|
||||
GuildAuditLogs.Entry = GuildAuditLogsEntry;
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
const { ChannelType } = require('discord-api-types/v9');
|
||||
const { Channel } = require('./Channel');
|
||||
const PermissionOverwrites = require('./PermissionOverwrites');
|
||||
const { Error } = require('../errors');
|
||||
const PermissionOverwriteManager = require('../managers/PermissionOverwriteManager');
|
||||
const { ChannelTypes, VoiceBasedChannelTypes } = require('../util/Constants');
|
||||
const { VoiceBasedChannelTypes } = require('../util/Constants');
|
||||
const Permissions = require('../util/Permissions');
|
||||
const Util = require('../util/Util');
|
||||
|
||||
@@ -321,7 +322,7 @@ class GuildChannel extends Channel {
|
||||
if (data.lockPermissions) {
|
||||
if (data.parent) {
|
||||
const newParent = this.guild.channels.resolve(data.parent);
|
||||
if (newParent?.type === 'GUILD_CATEGORY') {
|
||||
if (newParent?.type === 'GuildCategory') {
|
||||
permission_overwrites = newParent.permissionOverwrites.cache.map(o =>
|
||||
PermissionOverwrites.resolve(o, this.guild),
|
||||
);
|
||||
@@ -336,7 +337,7 @@ class GuildChannel extends Channel {
|
||||
const newData = await this.client.api.channels(this.id).patch({
|
||||
data: {
|
||||
name: (data.name ?? this.name).trim(),
|
||||
type: ChannelTypes[data.type],
|
||||
type: ChannelType[data.type],
|
||||
topic: data.topic,
|
||||
nsfw: data.nsfw,
|
||||
bitrate: data.bitrate ?? this.bitrate,
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||
const {
|
||||
GuildScheduledEventPrivacyLevel,
|
||||
GuildScheduledEventStatus,
|
||||
GuildScheduledEventEntityType,
|
||||
} = require('discord-api-types/v9');
|
||||
const Base = require('./Base');
|
||||
const { Error } = require('../errors');
|
||||
const {
|
||||
GuildScheduledEventEntityTypes,
|
||||
GuildScheduledEventStatuses,
|
||||
GuildScheduledEventPrivacyLevels,
|
||||
Endpoints,
|
||||
} = require('../util/Constants');
|
||||
const { Endpoints } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Represents a scheduled event in a {@link Guild}.
|
||||
@@ -88,19 +88,19 @@ class GuildScheduledEvent extends Base {
|
||||
* The privacy level of the guild scheduled event
|
||||
* @type {PrivacyLevel}
|
||||
*/
|
||||
this.privacyLevel = GuildScheduledEventPrivacyLevels[data.privacy_level];
|
||||
this.privacyLevel = GuildScheduledEventPrivacyLevel[data.privacy_level];
|
||||
|
||||
/**
|
||||
* The status of the guild scheduled event
|
||||
* @type {GuildScheduledEventStatus}
|
||||
*/
|
||||
this.status = GuildScheduledEventStatuses[data.status];
|
||||
this.status = GuildScheduledEventStatus[data.status];
|
||||
|
||||
/**
|
||||
* The type of hosting entity associated with the scheduled event
|
||||
* @type {GuildScheduledEventEntityType}
|
||||
*/
|
||||
this.entityType = GuildScheduledEventEntityTypes[data.entity_type];
|
||||
this.entityType = GuildScheduledEventEntityType[data.entity_type];
|
||||
|
||||
if ('entity_id' in data) {
|
||||
/**
|
||||
@@ -391,7 +391,7 @@ class GuildScheduledEvent extends Base {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isActive() {
|
||||
return GuildScheduledEventStatuses[this.status] === GuildScheduledEventStatuses.ACTIVE;
|
||||
return GuildScheduledEventStatus[this.status] === GuildScheduledEventStatus.Active;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -399,7 +399,7 @@ class GuildScheduledEvent extends Base {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isCanceled() {
|
||||
return GuildScheduledEventStatuses[this.status] === GuildScheduledEventStatuses.CANCELED;
|
||||
return GuildScheduledEventStatus[this.status] === GuildScheduledEventStatus.Canceled;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -407,7 +407,7 @@ class GuildScheduledEvent extends Base {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isCompleted() {
|
||||
return GuildScheduledEventStatuses[this.status] === GuildScheduledEventStatuses.COMPLETED;
|
||||
return GuildScheduledEventStatus[this.status] === GuildScheduledEventStatus.Completed;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -415,7 +415,7 @@ class GuildScheduledEvent extends Base {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isScheduled() {
|
||||
return GuildScheduledEventStatuses[this.status] === GuildScheduledEventStatuses.SCHEDULED;
|
||||
return GuildScheduledEventStatus[this.status] === GuildScheduledEventStatus.Scheduled;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||
const { InteractionType, ApplicationCommandType, ComponentType } = require('discord-api-types/v9');
|
||||
const Base = require('./Base');
|
||||
const { InteractionTypes, MessageComponentTypes, ApplicationCommandTypes } = require('../util/Constants');
|
||||
const Permissions = require('../util/Permissions');
|
||||
|
||||
/**
|
||||
@@ -17,7 +17,7 @@ class Interaction extends Base {
|
||||
* The interaction's type
|
||||
* @type {InteractionType}
|
||||
*/
|
||||
this.type = InteractionTypes[data.type];
|
||||
this.type = InteractionType[data.type];
|
||||
|
||||
/**
|
||||
* The interaction's id
|
||||
@@ -153,7 +153,7 @@ class Interaction extends Base {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isCommand() {
|
||||
return InteractionTypes[this.type] === InteractionTypes.APPLICATION_COMMAND;
|
||||
return InteractionType[this.type] === InteractionType.ApplicationCommand;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,7 +161,7 @@ class Interaction extends Base {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isChatInputCommand() {
|
||||
return InteractionTypes[this.type] === InteractionTypes.APPLICATION_COMMAND && typeof this.targetId === 'undefined';
|
||||
return InteractionType[this.type] === InteractionType.ApplicationCommand && typeof this.targetId === 'undefined';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,7 +169,7 @@ class Interaction extends Base {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isContextMenuCommand() {
|
||||
return InteractionTypes[this.type] === InteractionTypes.APPLICATION_COMMAND && typeof this.targetId !== 'undefined';
|
||||
return InteractionType[this.type] === InteractionType.ApplicationCommand && typeof this.targetId !== 'undefined';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,7 +177,7 @@ class Interaction extends Base {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isUserContextMenuCommand() {
|
||||
return this.isContextMenuCommand() && ApplicationCommandTypes[this.targetType] === ApplicationCommandTypes.USER;
|
||||
return this.isContextMenuCommand() && ApplicationCommandType[this.targetType] === ApplicationCommandType.User;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,7 +185,7 @@ class Interaction extends Base {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isMessageContextMenuCommand() {
|
||||
return this.isContextMenuCommand() && ApplicationCommandTypes[this.targetType] === ApplicationCommandTypes.MESSAGE;
|
||||
return this.isContextMenuCommand() && ApplicationCommandType[this.targetType] === ApplicationCommandType.Message;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,7 +193,7 @@ class Interaction extends Base {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isAutocomplete() {
|
||||
return InteractionTypes[this.type] === InteractionTypes.APPLICATION_COMMAND_AUTOCOMPLETE;
|
||||
return InteractionType[this.type] === InteractionType.ApplicationCommandAutocomplete;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,7 +201,7 @@ class Interaction extends Base {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isMessageComponent() {
|
||||
return InteractionTypes[this.type] === InteractionTypes.MESSAGE_COMPONENT;
|
||||
return InteractionType[this.type] === InteractionType.MessageComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,8 +210,8 @@ class Interaction extends Base {
|
||||
*/
|
||||
isButton() {
|
||||
return (
|
||||
InteractionTypes[this.type] === InteractionTypes.MESSAGE_COMPONENT &&
|
||||
MessageComponentTypes[this.componentType] === MessageComponentTypes.BUTTON
|
||||
InteractionType[this.type] === InteractionType.MessageComponent &&
|
||||
ComponentType[this.componentType] === ComponentType.Button
|
||||
);
|
||||
}
|
||||
|
||||
@@ -221,8 +221,8 @@ class Interaction extends Base {
|
||||
*/
|
||||
isSelectMenu() {
|
||||
return (
|
||||
InteractionTypes[this.type] === InteractionTypes.MESSAGE_COMPONENT &&
|
||||
MessageComponentTypes[this.componentType] === MessageComponentTypes.SELECT_MENU
|
||||
InteractionType[this.type] === InteractionType.MessageComponent &&
|
||||
ComponentType[this.componentType] === ComponentType.SelectMenu
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const { InteractionType, ComponentType } = require('discord-api-types/v9');
|
||||
const Collector = require('./interfaces/Collector');
|
||||
const { Events } = require('../util/Constants');
|
||||
const { InteractionTypes, MessageComponentTypes } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* @typedef {CollectorOptions} InteractionCollectorOptions
|
||||
@@ -66,7 +66,7 @@ class InteractionCollector extends Collector {
|
||||
*/
|
||||
this.interactionType =
|
||||
typeof options.interactionType === 'number'
|
||||
? InteractionTypes[options.interactionType]
|
||||
? InteractionType[options.interactionType]
|
||||
: options.interactionType ?? null;
|
||||
|
||||
/**
|
||||
@@ -74,9 +74,7 @@ class InteractionCollector extends Collector {
|
||||
* @type {?MessageComponentType}
|
||||
*/
|
||||
this.componentType =
|
||||
typeof options.componentType === 'number'
|
||||
? MessageComponentTypes[options.componentType]
|
||||
: options.componentType ?? null;
|
||||
typeof options.componentType === 'number' ? ComponentType[options.componentType] : options.componentType ?? null;
|
||||
|
||||
/**
|
||||
* The users that have interacted with this collector
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||
const { MessageType, InteractionType } = require('discord-api-types/v9');
|
||||
const Base = require('./Base');
|
||||
const BaseMessageComponent = require('./BaseMessageComponent');
|
||||
const ClientApplication = require('./ClientApplication');
|
||||
@@ -14,7 +15,7 @@ const ReactionCollector = require('./ReactionCollector');
|
||||
const { Sticker } = require('./Sticker');
|
||||
const { Error } = require('../errors');
|
||||
const ReactionManager = require('../managers/ReactionManager');
|
||||
const { InteractionTypes, MessageTypes, SystemMessageTypes } = require('../util/Constants');
|
||||
const { SystemMessageTypes } = require('../util/Constants');
|
||||
const MessageFlags = require('../util/MessageFlags');
|
||||
const Permissions = require('../util/Permissions');
|
||||
const Util = require('../util/Util');
|
||||
@@ -60,7 +61,7 @@ class Message extends Base {
|
||||
* The type of the message
|
||||
* @type {?MessageType}
|
||||
*/
|
||||
this.type = MessageTypes[data.type];
|
||||
this.type = MessageType[data.type];
|
||||
|
||||
/**
|
||||
* Whether or not this message was sent by Discord, not actually a user (e.g. pin notifications)
|
||||
@@ -333,7 +334,7 @@ class Message extends Base {
|
||||
*/
|
||||
this.interaction = {
|
||||
id: data.interaction.id,
|
||||
type: InteractionTypes[data.interaction.type],
|
||||
type: InteractionType[data.interaction.type],
|
||||
commandName: data.interaction.name,
|
||||
user: this.client.users._add(data.interaction.user),
|
||||
};
|
||||
@@ -502,7 +503,7 @@ class Message extends Base {
|
||||
createMessageComponentCollector(options = {}) {
|
||||
return new InteractionCollector(this.client, {
|
||||
...options,
|
||||
interactionType: InteractionTypes.MESSAGE_COMPONENT,
|
||||
interactionType: InteractionType.MessageComponent,
|
||||
message: this,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const { ComponentType } = require('discord-api-types/v9');
|
||||
const Interaction = require('./Interaction');
|
||||
const InteractionWebhook = require('./InteractionWebhook');
|
||||
const InteractionResponses = require('./interfaces/InteractionResponses');
|
||||
const { MessageComponentTypes } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Represents a message component interaction.
|
||||
@@ -84,11 +84,11 @@ class MessageComponentInteraction extends Interaction {
|
||||
/**
|
||||
* Resolves the type of a MessageComponent
|
||||
* @param {MessageComponentTypeResolvable} type The type to resolve
|
||||
* @returns {MessageComponentType}
|
||||
* @returns {ComponentType}
|
||||
* @private
|
||||
*/
|
||||
static resolveType(type) {
|
||||
return typeof type === 'string' ? type : MessageComponentTypes[type];
|
||||
return typeof type === 'string' ? type : ComponentType[type];
|
||||
}
|
||||
|
||||
// These are here only for documentation purposes - they are implemented by InteractionResponses
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const { ChannelTypes } = require('../util/Constants');
|
||||
const { ChannelType } = require('discord-api-types/v9');
|
||||
const Util = require('../util/Util');
|
||||
|
||||
/**
|
||||
@@ -112,7 +112,7 @@ class MessageMentions {
|
||||
this.crosspostedChannels = new Collection(crosspostedChannels);
|
||||
} else {
|
||||
this.crosspostedChannels = new Collection();
|
||||
const channelTypes = Object.keys(ChannelTypes);
|
||||
const channelTypes = Object.keys(ChannelType);
|
||||
for (const d of crosspostedChannels) {
|
||||
const type = channelTypes[d.type];
|
||||
this.crosspostedChannels.set(d.id, {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const { OverwriteType } = require('discord-api-types/v9');
|
||||
const Base = require('./Base');
|
||||
const { Role } = require('./Role');
|
||||
const { TypeError } = require('../errors');
|
||||
const { OverwriteTypes } = require('../util/Constants');
|
||||
const Permissions = require('../util/Permissions');
|
||||
|
||||
/**
|
||||
@@ -37,7 +37,7 @@ class PermissionOverwrites extends Base {
|
||||
* The type of this overwrite
|
||||
* @type {OverwriteType}
|
||||
*/
|
||||
this.type = typeof data.type === 'number' ? OverwriteTypes[data.type] : data.type;
|
||||
this.type = typeof data.type === 'number' ? OverwriteType[data.type] : data.type;
|
||||
}
|
||||
|
||||
if ('deny' in data) {
|
||||
@@ -71,7 +71,7 @@ class PermissionOverwrites extends Base {
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async edit(options, reason) {
|
||||
await this.channel.permissionOverwrites.upsert(this.id, options, { type: OverwriteTypes[this.type], reason }, this);
|
||||
await this.channel.permissionOverwrites.upsert(this.id, options, { type: OverwriteType[this.type], reason }, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ class PermissionOverwrites extends Base {
|
||||
toJSON() {
|
||||
return {
|
||||
id: this.id,
|
||||
type: OverwriteTypes[this.type],
|
||||
type: OverwriteType[this.type],
|
||||
allow: this.allow,
|
||||
deny: this.deny,
|
||||
};
|
||||
@@ -171,10 +171,10 @@ class PermissionOverwrites extends Base {
|
||||
*/
|
||||
static resolve(overwrite, guild) {
|
||||
if (overwrite instanceof this) return overwrite.toJSON();
|
||||
if (typeof overwrite.id === 'string' && overwrite.type in OverwriteTypes) {
|
||||
if (typeof overwrite.id === 'string' && overwrite.type in OverwriteType) {
|
||||
return {
|
||||
id: overwrite.id,
|
||||
type: OverwriteTypes[overwrite.type],
|
||||
type: OverwriteType[overwrite.type],
|
||||
allow: Permissions.resolve(overwrite.allow ?? Permissions.defaultBit).toString(),
|
||||
deny: Permissions.resolve(overwrite.deny ?? Permissions.defaultBit).toString(),
|
||||
};
|
||||
@@ -182,7 +182,7 @@ class PermissionOverwrites extends Base {
|
||||
|
||||
const userOrRole = guild.roles.resolve(overwrite.id) ?? guild.client.users.resolve(overwrite.id);
|
||||
if (!userOrRole) throw new TypeError('INVALID_TYPE', 'parameter', 'User nor a Role');
|
||||
const type = userOrRole instanceof Role ? OverwriteTypes.role : OverwriteTypes.member;
|
||||
const type = userOrRole instanceof Role ? OverwriteType.Role : OverwriteType.Member;
|
||||
|
||||
return {
|
||||
id: userOrRole.id,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const { ActivityType } = require('discord-api-types/v9');
|
||||
const Base = require('./Base');
|
||||
const { Emoji } = require('./Emoji');
|
||||
const ActivityFlags = require('../util/ActivityFlags');
|
||||
const { ActivityTypes } = require('../util/Constants');
|
||||
const Util = require('../util/Util');
|
||||
|
||||
/**
|
||||
@@ -168,7 +168,7 @@ class Activity {
|
||||
* The activity status's type
|
||||
* @type {ActivityType}
|
||||
*/
|
||||
this.type = typeof data.type === 'number' ? ActivityTypes[data.type] : data.type;
|
||||
this.type = typeof data.type === 'number' ? ActivityType[data.type] : data.type;
|
||||
|
||||
/**
|
||||
* If the activity is being streamed, a link to the stream
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||
const { StageInstancePrivacyLevel } = require('discord-api-types/v9');
|
||||
const Base = require('./Base');
|
||||
const { PrivacyLevels } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Represents a stage instance.
|
||||
@@ -49,9 +49,9 @@ class StageInstance extends Base {
|
||||
if ('privacy_level' in data) {
|
||||
/**
|
||||
* The privacy level of the stage instance
|
||||
* @type {PrivacyLevel}
|
||||
* @type {StageInstancePrivacyLevel}
|
||||
*/
|
||||
this.privacyLevel = PrivacyLevels[data.privacy_level];
|
||||
this.privacyLevel = StageInstancePrivacyLevel[data.privacy_level];
|
||||
}
|
||||
|
||||
if ('discoverable_disabled' in data) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||
const { StickerType, StickerFormatType } = require('discord-api-types/v9');
|
||||
const Base = require('./Base');
|
||||
const { StickerFormatTypes, StickerTypes } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Represents a Sticker.
|
||||
@@ -37,7 +37,7 @@ class Sticker extends Base {
|
||||
* The type of the sticker
|
||||
* @type {?StickerType}
|
||||
*/
|
||||
this.type = StickerTypes[sticker.type];
|
||||
this.type = StickerType[sticker.type];
|
||||
} else {
|
||||
this.type ??= null;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ class Sticker extends Base {
|
||||
* The format of the sticker
|
||||
* @type {StickerFormatType}
|
||||
*/
|
||||
this.format = StickerFormatTypes[sticker.format_type];
|
||||
this.format = StickerFormatType[sticker.format_type];
|
||||
}
|
||||
|
||||
if ('name' in sticker) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { TeamMemberMembershipState } = require('discord-api-types/v9');
|
||||
const Base = require('./Base');
|
||||
const { MembershipStates } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Represents a Client OAuth2 Application Team Member.
|
||||
@@ -32,9 +32,9 @@ class TeamMember extends Base {
|
||||
if ('membership_state' in data) {
|
||||
/**
|
||||
* The permissions this Team Member has with regard to the team
|
||||
* @type {MembershipState}
|
||||
* @type {TeamMemberMembershipState}
|
||||
*/
|
||||
this.membershipState = MembershipStates[data.membership_state];
|
||||
this.membershipState = TeamMemberMembershipState[data.membership_state];
|
||||
}
|
||||
|
||||
if ('user' in data) {
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
const process = require('node:process');
|
||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||
const { WebhookType } = require('discord-api-types/v9');
|
||||
const MessagePayload = require('./MessagePayload');
|
||||
const { Error } = require('../errors');
|
||||
const { WebhookTypes } = require('../util/Constants');
|
||||
const DataResolver = require('../util/DataResolver');
|
||||
|
||||
let deprecationEmittedForFetchMessage = false;
|
||||
@@ -59,7 +59,7 @@ class Webhook {
|
||||
* The type of the webhook
|
||||
* @type {WebhookType}
|
||||
*/
|
||||
this.type = WebhookTypes[data.type];
|
||||
this.type = WebhookType[data.type];
|
||||
}
|
||||
|
||||
if ('guild_id' in data) {
|
||||
@@ -416,7 +416,7 @@ class Webhook {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isChannelFollower() {
|
||||
return this.type === 'Channel Follower';
|
||||
return this.type === 'ChannelFollower';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { InteractionResponseType } = require('discord-api-types/v9');
|
||||
const { Error } = require('../../errors');
|
||||
const { InteractionResponseTypes } = require('../../util/Constants');
|
||||
const MessageFlags = require('../../util/MessageFlags');
|
||||
const MessagePayload = require('../MessagePayload');
|
||||
|
||||
@@ -56,7 +56,7 @@ class InteractionResponses {
|
||||
this.ephemeral = options.ephemeral ?? false;
|
||||
await this.client.api.interactions(this.id, this.token).callback.post({
|
||||
data: {
|
||||
type: InteractionResponseTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE,
|
||||
type: InteractionResponseType.DeferredChannelMessageWithSource,
|
||||
data: {
|
||||
flags: options.ephemeral ? MessageFlags.FLAGS.EPHEMERAL : undefined,
|
||||
},
|
||||
@@ -98,7 +98,7 @@ class InteractionResponses {
|
||||
|
||||
await this.client.api.interactions(this.id, this.token).callback.post({
|
||||
data: {
|
||||
type: InteractionResponseTypes.CHANNEL_MESSAGE_WITH_SOURCE,
|
||||
type: InteractionResponseType.ChannelMessageWithSource,
|
||||
data,
|
||||
},
|
||||
files,
|
||||
@@ -180,7 +180,7 @@ class InteractionResponses {
|
||||
if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
|
||||
await this.client.api.interactions(this.id, this.token).callback.post({
|
||||
data: {
|
||||
type: InteractionResponseTypes.DEFERRED_MESSAGE_UPDATE,
|
||||
type: InteractionResponseType.DeferredMessageUpdate,
|
||||
},
|
||||
auth: false,
|
||||
});
|
||||
@@ -213,7 +213,7 @@ class InteractionResponses {
|
||||
|
||||
await this.client.api.interactions(this.id, this.token).callback.post({
|
||||
data: {
|
||||
type: InteractionResponseTypes.UPDATE_MESSAGE,
|
||||
type: InteractionResponseType.UpdateMessage,
|
||||
data,
|
||||
},
|
||||
files,
|
||||
|
||||
@@ -5,8 +5,8 @@ const MessageCollector = require('../MessageCollector');
|
||||
const MessagePayload = require('../MessagePayload');
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||
const { InteractionTypes } = require('../../util/Constants');
|
||||
const { TypeError, Error } = require('../../errors');
|
||||
const { InteractionType } = require('discord-api-types/v9');
|
||||
const InteractionCollector = require('../InteractionCollector');
|
||||
|
||||
/**
|
||||
@@ -249,7 +249,7 @@ class TextBasedChannel {
|
||||
createMessageComponentCollector(options = {}) {
|
||||
return new InteractionCollector(this.client, {
|
||||
...options,
|
||||
interactionType: InteractionTypes.MESSAGE_COMPONENT,
|
||||
interactionType: InteractionType.MessageComponent,
|
||||
channel: this,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -478,56 +478,6 @@ exports.SystemMessageTypes = exports.MessageTypes.filter(
|
||||
type => type && !['DEFAULT', 'REPLY', 'CHAT_INPUT_COMMAND', 'CONTEXT_MENU_COMMAND'].includes(type),
|
||||
);
|
||||
|
||||
/**
|
||||
* <info>Bots cannot set a `CUSTOM` activity type, it is only for custom statuses received from users</info>
|
||||
* The type of an activity of a user's presence. Here are the available types:
|
||||
* * PLAYING
|
||||
* * STREAMING
|
||||
* * LISTENING
|
||||
* * WATCHING
|
||||
* * CUSTOM
|
||||
* * COMPETING
|
||||
* @typedef {string} ActivityType
|
||||
* @see {@link https://discord.com/developers/docs/game-sdk/activities#data-models-activitytype-enum}
|
||||
*/
|
||||
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
|
||||
* <warn>Store channels are deprecated and will be removed from Discord in March 2022. See
|
||||
* [Self-serve Game Selling Deprecation](https://support-dev.discord.com/hc/en-us/articles/4414590563479)
|
||||
* for more information.</warn>
|
||||
* * `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
|
||||
* @see {@link https://discord.com/developers/docs/resources/channel#channel-object-channel-types}
|
||||
*/
|
||||
exports.ChannelTypes = createEnum([
|
||||
'GUILD_TEXT',
|
||||
'DM',
|
||||
'GUILD_VOICE',
|
||||
'GROUP_DM',
|
||||
'GUILD_CATEGORY',
|
||||
'GUILD_NEWS',
|
||||
'GUILD_STORE',
|
||||
...Array(3).fill(null),
|
||||
// 10
|
||||
'GUILD_NEWS_THREAD',
|
||||
'GUILD_PUBLIC_THREAD',
|
||||
'GUILD_PRIVATE_THREAD',
|
||||
'GUILD_STAGE_VOICE',
|
||||
]);
|
||||
|
||||
/**
|
||||
* The channels that are text-based.
|
||||
* * DMChannel
|
||||
@@ -606,558 +556,6 @@ exports.Colors = {
|
||||
NOT_QUITE_BLACK: 0x23272a,
|
||||
};
|
||||
|
||||
/**
|
||||
* The value set for the explicit content filter levels for a guild:
|
||||
* * DISABLED
|
||||
* * MEMBERS_WITHOUT_ROLES
|
||||
* * ALL_MEMBERS
|
||||
* @typedef {string} ExplicitContentFilterLevel
|
||||
* @see {@link https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level}
|
||||
*/
|
||||
exports.ExplicitContentFilterLevels = createEnum(['DISABLED', 'MEMBERS_WITHOUT_ROLES', 'ALL_MEMBERS']);
|
||||
|
||||
/**
|
||||
* The value set for the verification levels for a guild:
|
||||
* * NONE
|
||||
* * LOW
|
||||
* * MEDIUM
|
||||
* * HIGH
|
||||
* * VERY_HIGH
|
||||
* @typedef {string} VerificationLevel
|
||||
* @see {@link https://discord.com/developers/docs/resources/guild#guild-object-verification-level}
|
||||
*/
|
||||
exports.VerificationLevels = createEnum(['NONE', 'LOW', 'MEDIUM', 'HIGH', 'VERY_HIGH']);
|
||||
|
||||
/**
|
||||
* An error encountered while performing an API request. Here are the potential errors:
|
||||
* * UNKNOWN_ACCOUNT
|
||||
* * UNKNOWN_APPLICATION
|
||||
* * UNKNOWN_CHANNEL
|
||||
* * UNKNOWN_GUILD
|
||||
* * UNKNOWN_INTEGRATION
|
||||
* * UNKNOWN_INVITE
|
||||
* * UNKNOWN_MEMBER
|
||||
* * UNKNOWN_MESSAGE
|
||||
* * UNKNOWN_OVERWRITE
|
||||
* * UNKNOWN_PROVIDER
|
||||
* * UNKNOWN_ROLE
|
||||
* * UNKNOWN_TOKEN
|
||||
* * UNKNOWN_USER
|
||||
* * UNKNOWN_EMOJI
|
||||
* * UNKNOWN_WEBHOOK
|
||||
* * UNKNOWN_WEBHOOK_SERVICE
|
||||
* * UNKNOWN_SESSION
|
||||
* * UNKNOWN_BAN
|
||||
* * UNKNOWN_SKU
|
||||
* * UNKNOWN_STORE_LISTING
|
||||
* * UNKNOWN_ENTITLEMENT
|
||||
* * UNKNOWN_BUILD
|
||||
* * UNKNOWN_LOBBY
|
||||
* * UNKNOWN_BRANCH
|
||||
* * UNKNOWN_STORE_DIRECTORY_LAYOUT
|
||||
* * UNKNOWN_REDISTRIBUTABLE
|
||||
* * UNKNOWN_GIFT_CODE
|
||||
* * UNKNOWN_STREAM
|
||||
* * UNKNOWN_PREMIUM_SERVER_SUBSCRIBE_COOLDOWN
|
||||
* * UNKNOWN_GUILD_TEMPLATE
|
||||
* * UNKNOWN_DISCOVERABLE_SERVER_CATEGORY
|
||||
* * UNKNOWN_STICKER
|
||||
* * UNKNOWN_INTERACTION
|
||||
* * UNKNOWN_APPLICATION_COMMAND
|
||||
* * UNKNOWN_APPLICATION_COMMAND_PERMISSIONS
|
||||
* * UNKNOWN_STAGE_INSTANCE
|
||||
* * UNKNOWN_GUILD_MEMBER_VERIFICATION_FORM
|
||||
* * UNKNOWN_GUILD_WELCOME_SCREEN
|
||||
* * UNKNOWN_GUILD_SCHEDULED_EVENT
|
||||
* * UNKNOWN_GUILD_SCHEDULED_EVENT_USER
|
||||
* * BOT_PROHIBITED_ENDPOINT
|
||||
* * BOT_ONLY_ENDPOINT
|
||||
* * CANNOT_SEND_EXPLICIT_CONTENT
|
||||
* * NOT_AUTHORIZED
|
||||
* * SLOWMODE_RATE_LIMIT
|
||||
* * ACCOUNT_OWNER_ONLY
|
||||
* * ANNOUNCEMENT_EDIT_LIMIT_EXCEEDED
|
||||
* * CHANNEL_HIT_WRITE_RATELIMIT
|
||||
* * SERVER_HIT_WRITE_RATELIMIT
|
||||
* * CONTENT_NOT_ALLOWED
|
||||
* * GUILD_PREMIUM_LEVEL_TOO_LOW
|
||||
* * MAXIMUM_GUILDS
|
||||
* * MAXIMUM_FRIENDS
|
||||
* * MAXIMUM_PINS
|
||||
* * MAXIMUM_RECIPIENTS
|
||||
* * MAXIMUM_ROLES
|
||||
* * MAXIMUM_WEBHOOKS
|
||||
* * MAXIMUM_EMOJIS
|
||||
* * MAXIMUM_REACTIONS
|
||||
* * MAXIMUM_CHANNELS
|
||||
* * MAXIMUM_ATTACHMENTS
|
||||
* * MAXIMUM_INVITES
|
||||
* * MAXIMUM_ANIMATED_EMOJIS
|
||||
* * MAXIMUM_SERVER_MEMBERS
|
||||
* * MAXIMUM_NUMBER_OF_SERVER_CATEGORIES
|
||||
* * GUILD_ALREADY_HAS_TEMPLATE
|
||||
* * MAXIMUM_THREAD_PARTICIPANTS
|
||||
* * MAXIMUM_NON_GUILD_MEMBERS_BANS
|
||||
* * MAXIMUM_BAN_FETCHES
|
||||
* * MAXIMUM_NUMBER_OF_UNCOMPLETED_GUILD_SCHEDULED_EVENTS_REACHED
|
||||
* * MAXIMUM_NUMBER_OF_STICKERS_REACHED
|
||||
* * MAXIMUM_PRUNE_REQUESTS
|
||||
* * MAXIMUM_GUILD_WIDGET_SETTINGS_UPDATE
|
||||
* * UNAUTHORIZED
|
||||
* * ACCOUNT_VERIFICATION_REQUIRED
|
||||
* * DIRECT_MESSAGES_TOO_FAST
|
||||
* * REQUEST_ENTITY_TOO_LARGE
|
||||
* * FEATURE_TEMPORARILY_DISABLED
|
||||
* * USER_BANNED
|
||||
* * TARGET_USER_NOT_CONNECTED_TO_VOICE
|
||||
* * ALREADY_CROSSPOSTED
|
||||
* * MISSING_ACCESS
|
||||
* * INVALID_ACCOUNT_TYPE
|
||||
* * CANNOT_EXECUTE_ON_DM
|
||||
* * EMBED_DISABLED
|
||||
* * CANNOT_EDIT_MESSAGE_BY_OTHER
|
||||
* * CANNOT_SEND_EMPTY_MESSAGE
|
||||
* * CANNOT_MESSAGE_USER
|
||||
* * CANNOT_SEND_MESSAGES_IN_VOICE_CHANNEL
|
||||
* * CHANNEL_VERIFICATION_LEVEL_TOO_HIGH
|
||||
* * OAUTH2_APPLICATION_BOT_ABSENT
|
||||
* * MAXIMUM_OAUTH2_APPLICATIONS
|
||||
* * INVALID_OAUTH_STATE
|
||||
* * MISSING_PERMISSIONS
|
||||
* * INVALID_AUTHENTICATION_TOKEN
|
||||
* * NOTE_TOO_LONG
|
||||
* * INVALID_BULK_DELETE_QUANTITY
|
||||
* * CANNOT_PIN_MESSAGE_IN_OTHER_CHANNEL
|
||||
* * INVALID_OR_TAKEN_INVITE_CODE
|
||||
* * CANNOT_EXECUTE_ON_SYSTEM_MESSAGE
|
||||
* * CANNOT_EXECUTE_ON_CHANNEL_TYPE
|
||||
* * INVALID_OAUTH_TOKEN
|
||||
* * MISSING_OAUTH_SCOPE
|
||||
* * INVALID_WEBHOOK_TOKEN
|
||||
* * INVALID_ROLE
|
||||
* * INVALID_RECIPIENTS
|
||||
* * BULK_DELETE_MESSAGE_TOO_OLD
|
||||
* * INVALID_FORM_BODY
|
||||
* * INVITE_ACCEPTED_TO_GUILD_NOT_CONTAINING_BOT
|
||||
* * INVALID_API_VERSION
|
||||
* * FILE_UPLOADED_EXCEEDS_MAXIMUM_SIZE
|
||||
* * INVALID_FILE_UPLOADED
|
||||
* * CANNOT_SELF_REDEEM_GIFT
|
||||
* * INVALID_GUILD
|
||||
* * PAYMENT_SOURCE_REQUIRED
|
||||
* * CANNOT_DELETE_COMMUNITY_REQUIRED_CHANNEL
|
||||
* * INVALID_STICKER_SENT
|
||||
* * INVALID_OPERATION_ON_ARCHIVED_THREAD
|
||||
* * INVALID_THREAD_NOTIFICATION_SETTINGS
|
||||
* * PARAMETER_EARLIER_THAN_CREATION
|
||||
* * GUILD_NOT_AVAILABLE_IN_LOCATION
|
||||
* * GUILD_MONETIZATION_REQUIRED
|
||||
* * INSUFFICIENT_BOOSTS
|
||||
* * INVALID_JSON
|
||||
* * TWO_FACTOR_REQUIRED
|
||||
* * NO_USERS_WITH_DISCORDTAG_EXIST
|
||||
* * REACTION_BLOCKED
|
||||
* * RESOURCE_OVERLOADED
|
||||
* * STAGE_ALREADY_OPEN
|
||||
* * CANNOT_REPLY_WITHOUT_READ_MESSAGE_HISTORY_PERMISSION
|
||||
* * MESSAGE_ALREADY_HAS_THREAD
|
||||
* * THREAD_LOCKED
|
||||
* * MAXIMUM_ACTIVE_THREADS
|
||||
* * MAXIMUM_ACTIVE_ANNOUNCEMENT_THREAD
|
||||
* * INVALID_JSON_FOR_UPLOADED_LOTTIE_FILE
|
||||
* * UPLOADED_LOTTIES_CANNOT_CONTAIN_RASTERIZED_IMAGES
|
||||
* * STICKER_MAXIMUM_FRAMERATE_EXCEEDED
|
||||
* * STICKER_FRAME_COUNT_EXCEEDS_MAXIMUM_OF_1000_FRAMES
|
||||
* * LOTTIE_ANIMATION_MAXIMUM_DIMENSIONS_EXCEEDED
|
||||
* * STICKER_FRAME_RATE_IS_TOO_SMALL_OR_TOO_LARGE
|
||||
* * STICKER_ANIMATION_DURATION_EXCEEDS_MAXIMUM_OF_5_SECONDS
|
||||
* * CANNOT_UPDATE_A_FINISHED_EVENT
|
||||
* * FAILED_TO_CREATE_STAGE_NEEDED_FOR_STAGE_EVENT
|
||||
* @typedef {string} APIError
|
||||
* @see {@link https://discord.com/developers/docs/topics/opcodes-and-status-codes#json-json-error-codes}
|
||||
*/
|
||||
exports.APIErrors = {
|
||||
UNKNOWN_ACCOUNT: 10001,
|
||||
UNKNOWN_APPLICATION: 10002,
|
||||
UNKNOWN_CHANNEL: 10003,
|
||||
UNKNOWN_GUILD: 10004,
|
||||
UNKNOWN_INTEGRATION: 10005,
|
||||
UNKNOWN_INVITE: 10006,
|
||||
UNKNOWN_MEMBER: 10007,
|
||||
UNKNOWN_MESSAGE: 10008,
|
||||
UNKNOWN_OVERWRITE: 10009,
|
||||
UNKNOWN_PROVIDER: 10010,
|
||||
UNKNOWN_ROLE: 10011,
|
||||
UNKNOWN_TOKEN: 10012,
|
||||
UNKNOWN_USER: 10013,
|
||||
UNKNOWN_EMOJI: 10014,
|
||||
UNKNOWN_WEBHOOK: 10015,
|
||||
UNKNOWN_WEBHOOK_SERVICE: 10016,
|
||||
UNKNOWN_SESSION: 10020,
|
||||
UNKNOWN_BAN: 10026,
|
||||
UNKNOWN_SKU: 10027,
|
||||
UNKNOWN_STORE_LISTING: 10028,
|
||||
UNKNOWN_ENTITLEMENT: 10029,
|
||||
UNKNOWN_BUILD: 10030,
|
||||
UNKNOWN_LOBBY: 10031,
|
||||
UNKNOWN_BRANCH: 10032,
|
||||
UNKNOWN_STORE_DIRECTORY_LAYOUT: 10033,
|
||||
UNKNOWN_REDISTRIBUTABLE: 10036,
|
||||
UNKNOWN_GIFT_CODE: 10038,
|
||||
UNKNOWN_STREAM: 10049,
|
||||
UNKNOWN_PREMIUM_SERVER_SUBSCRIBE_COOLDOWN: 10050,
|
||||
UNKNOWN_GUILD_TEMPLATE: 10057,
|
||||
UNKNOWN_DISCOVERABLE_SERVER_CATEGORY: 10059,
|
||||
UNKNOWN_STICKER: 10060,
|
||||
UNKNOWN_INTERACTION: 10062,
|
||||
UNKNOWN_APPLICATION_COMMAND: 10063,
|
||||
UNKNOWN_APPLICATION_COMMAND_PERMISSIONS: 10066,
|
||||
UNKNOWN_STAGE_INSTANCE: 10067,
|
||||
UNKNOWN_GUILD_MEMBER_VERIFICATION_FORM: 10068,
|
||||
UNKNOWN_GUILD_WELCOME_SCREEN: 10069,
|
||||
UNKNOWN_GUILD_SCHEDULED_EVENT: 10070,
|
||||
UNKNOWN_GUILD_SCHEDULED_EVENT_USER: 10071,
|
||||
BOT_PROHIBITED_ENDPOINT: 20001,
|
||||
BOT_ONLY_ENDPOINT: 20002,
|
||||
CANNOT_SEND_EXPLICIT_CONTENT: 20009,
|
||||
NOT_AUTHORIZED: 20012,
|
||||
SLOWMODE_RATE_LIMIT: 20016,
|
||||
ACCOUNT_OWNER_ONLY: 20018,
|
||||
ANNOUNCEMENT_EDIT_LIMIT_EXCEEDED: 20022,
|
||||
CHANNEL_HIT_WRITE_RATELIMIT: 20028,
|
||||
SERVER_HIT_WRITE_RATELIMIT: 20029,
|
||||
CONTENT_NOT_ALLOWED: 20031,
|
||||
GUILD_PREMIUM_LEVEL_TOO_LOW: 20035,
|
||||
MAXIMUM_GUILDS: 30001,
|
||||
MAXIMUM_FRIENDS: 30002,
|
||||
MAXIMUM_PINS: 30003,
|
||||
MAXIMUM_RECIPIENTS: 30004,
|
||||
MAXIMUM_ROLES: 30005,
|
||||
MAXIMUM_WEBHOOKS: 30007,
|
||||
MAXIMUM_EMOJIS: 30008,
|
||||
MAXIMUM_REACTIONS: 30010,
|
||||
MAXIMUM_CHANNELS: 30013,
|
||||
MAXIMUM_ATTACHMENTS: 30015,
|
||||
MAXIMUM_INVITES: 30016,
|
||||
MAXIMUM_ANIMATED_EMOJIS: 30018,
|
||||
MAXIMUM_SERVER_MEMBERS: 30019,
|
||||
MAXIMUM_NUMBER_OF_SERVER_CATEGORIES: 30030,
|
||||
GUILD_ALREADY_HAS_TEMPLATE: 30031,
|
||||
MAXIMUM_THREAD_PARTICIPANTS: 30033,
|
||||
MAXIMUM_NON_GUILD_MEMBERS_BANS: 30035,
|
||||
MAXIMUM_BAN_FETCHES: 30037,
|
||||
MAXIMUM_NUMBER_OF_UNCOMPLETED_GUILD_SCHEDULED_EVENTS_REACHED: 30038,
|
||||
MAXIMUM_NUMBER_OF_STICKERS_REACHED: 30039,
|
||||
MAXIMUM_PRUNE_REQUESTS: 30040,
|
||||
MAXIMUM_GUILD_WIDGET_SETTINGS_UPDATE: 30042,
|
||||
UNAUTHORIZED: 40001,
|
||||
ACCOUNT_VERIFICATION_REQUIRED: 40002,
|
||||
DIRECT_MESSAGES_TOO_FAST: 40003,
|
||||
REQUEST_ENTITY_TOO_LARGE: 40005,
|
||||
FEATURE_TEMPORARILY_DISABLED: 40006,
|
||||
USER_BANNED: 40007,
|
||||
TARGET_USER_NOT_CONNECTED_TO_VOICE: 40032,
|
||||
ALREADY_CROSSPOSTED: 40033,
|
||||
MISSING_ACCESS: 50001,
|
||||
INVALID_ACCOUNT_TYPE: 50002,
|
||||
CANNOT_EXECUTE_ON_DM: 50003,
|
||||
EMBED_DISABLED: 50004,
|
||||
CANNOT_EDIT_MESSAGE_BY_OTHER: 50005,
|
||||
CANNOT_SEND_EMPTY_MESSAGE: 50006,
|
||||
CANNOT_MESSAGE_USER: 50007,
|
||||
CANNOT_SEND_MESSAGES_IN_VOICE_CHANNEL: 50008,
|
||||
CHANNEL_VERIFICATION_LEVEL_TOO_HIGH: 50009,
|
||||
OAUTH2_APPLICATION_BOT_ABSENT: 50010,
|
||||
MAXIMUM_OAUTH2_APPLICATIONS: 50011,
|
||||
INVALID_OAUTH_STATE: 50012,
|
||||
MISSING_PERMISSIONS: 50013,
|
||||
INVALID_AUTHENTICATION_TOKEN: 50014,
|
||||
NOTE_TOO_LONG: 50015,
|
||||
INVALID_BULK_DELETE_QUANTITY: 50016,
|
||||
CANNOT_PIN_MESSAGE_IN_OTHER_CHANNEL: 50019,
|
||||
INVALID_OR_TAKEN_INVITE_CODE: 50020,
|
||||
CANNOT_EXECUTE_ON_SYSTEM_MESSAGE: 50021,
|
||||
CANNOT_EXECUTE_ON_CHANNEL_TYPE: 50024,
|
||||
INVALID_OAUTH_TOKEN: 50025,
|
||||
MISSING_OAUTH_SCOPE: 50026,
|
||||
INVALID_WEBHOOK_TOKEN: 50027,
|
||||
INVALID_ROLE: 50028,
|
||||
INVALID_RECIPIENTS: 50033,
|
||||
BULK_DELETE_MESSAGE_TOO_OLD: 50034,
|
||||
INVALID_FORM_BODY: 50035,
|
||||
INVITE_ACCEPTED_TO_GUILD_NOT_CONTAINING_BOT: 50036,
|
||||
INVALID_API_VERSION: 50041,
|
||||
FILE_UPLOADED_EXCEEDS_MAXIMUM_SIZE: 50045,
|
||||
INVALID_FILE_UPLOADED: 50046,
|
||||
CANNOT_SELF_REDEEM_GIFT: 50054,
|
||||
INVALID_GUILD: 50055,
|
||||
PAYMENT_SOURCE_REQUIRED: 50070,
|
||||
CANNOT_DELETE_COMMUNITY_REQUIRED_CHANNEL: 50074,
|
||||
INVALID_STICKER_SENT: 50081,
|
||||
INVALID_OPERATION_ON_ARCHIVED_THREAD: 50083,
|
||||
INVALID_THREAD_NOTIFICATION_SETTINGS: 50084,
|
||||
PARAMETER_EARLIER_THAN_CREATION: 50085,
|
||||
GUILD_NOT_AVAILABLE_IN_LOCATION: 50095,
|
||||
GUILD_MONETIZATION_REQUIRED: 50097,
|
||||
INSUFFICIENT_BOOSTS: 50101,
|
||||
INVALID_JSON: 50109,
|
||||
TWO_FACTOR_REQUIRED: 60003,
|
||||
NO_USERS_WITH_DISCORDTAG_EXIST: 80004,
|
||||
REACTION_BLOCKED: 90001,
|
||||
RESOURCE_OVERLOADED: 130000,
|
||||
STAGE_ALREADY_OPEN: 150006,
|
||||
CANNOT_REPLY_WITHOUT_READ_MESSAGE_HISTORY_PERMISSION: 160002,
|
||||
MESSAGE_ALREADY_HAS_THREAD: 160004,
|
||||
THREAD_LOCKED: 160005,
|
||||
MAXIMUM_ACTIVE_THREADS: 160006,
|
||||
MAXIMUM_ACTIVE_ANNOUNCEMENT_THREADS: 160007,
|
||||
INVALID_JSON_FOR_UPLOADED_LOTTIE_FILE: 170001,
|
||||
UPLOADED_LOTTIES_CANNOT_CONTAIN_RASTERIZED_IMAGES: 170002,
|
||||
STICKER_MAXIMUM_FRAMERATE_EXCEEDED: 170003,
|
||||
STICKER_FRAME_COUNT_EXCEEDS_MAXIMUM_OF_1000_FRAMES: 170004,
|
||||
LOTTIE_ANIMATION_MAXIMUM_DIMENSIONS_EXCEEDED: 170005,
|
||||
STICKER_FRAME_RATE_IS_TOO_SMALL_OR_TOO_LARGE: 170006,
|
||||
STICKER_ANIMATION_DURATION_EXCEEDS_MAXIMUM_OF_5_SECONDS: 170007,
|
||||
CANNOT_UPDATE_A_FINISHED_EVENT: 180000,
|
||||
FAILED_TO_CREATE_STAGE_NEEDED_FOR_STAGE_EVENT: 180002,
|
||||
};
|
||||
|
||||
/**
|
||||
* The value set for a guild's default message notifications, e.g. `ALL_MESSAGES`. Here are the available types:
|
||||
* * ALL_MESSAGES
|
||||
* * ONLY_MENTIONS
|
||||
* @typedef {string} DefaultMessageNotificationLevel
|
||||
* @see {@link https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level}
|
||||
*/
|
||||
exports.DefaultMessageNotificationLevels = createEnum(['ALL_MESSAGES', 'ONLY_MENTIONS']);
|
||||
|
||||
/**
|
||||
* The value set for a team member's membership state:
|
||||
* * INVITED
|
||||
* * ACCEPTED
|
||||
* @typedef {string} MembershipState
|
||||
* @see {@link https://discord.com/developers/docs/topics/teams#data-models-membership-state-enum}
|
||||
*/
|
||||
exports.MembershipStates = createEnum([null, 'INVITED', 'ACCEPTED']);
|
||||
|
||||
/**
|
||||
* The value set for a webhook's type:
|
||||
* * Incoming
|
||||
* * Channel Follower
|
||||
* * Application
|
||||
* @typedef {string} WebhookType
|
||||
* @see {@link https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types}
|
||||
*/
|
||||
exports.WebhookTypes = createEnum([null, 'Incoming', 'Channel Follower', 'Application']);
|
||||
|
||||
/**
|
||||
* The value set for a sticker's type:
|
||||
* * STANDARD
|
||||
* * GUILD
|
||||
* @typedef {string} StickerType
|
||||
* @see {@link https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-types}
|
||||
*/
|
||||
exports.StickerTypes = createEnum([null, 'STANDARD', 'GUILD']);
|
||||
|
||||
/**
|
||||
* The value set for a sticker's format type:
|
||||
* * PNG
|
||||
* * APNG
|
||||
* * LOTTIE
|
||||
* @typedef {string} StickerFormatType
|
||||
* @see {@link https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types}
|
||||
*/
|
||||
exports.StickerFormatTypes = createEnum([null, 'PNG', 'APNG', 'LOTTIE']);
|
||||
|
||||
/**
|
||||
* An overwrite type:
|
||||
* * role
|
||||
* * member
|
||||
* @typedef {string} OverwriteType
|
||||
* @see {@link https://discord.com/developers/docs/resources/channel#overwrite-object-overwrite-structure}
|
||||
*/
|
||||
exports.OverwriteTypes = createEnum(['role', 'member']);
|
||||
|
||||
/* eslint-disable max-len */
|
||||
/**
|
||||
* The type of an {@link ApplicationCommand} object:
|
||||
* * CHAT_INPUT
|
||||
* * USER
|
||||
* * MESSAGE
|
||||
* @typedef {string} ApplicationCommandType
|
||||
* @see {@link https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types}
|
||||
*/
|
||||
exports.ApplicationCommandTypes = createEnum([null, 'CHAT_INPUT', 'USER', 'MESSAGE']);
|
||||
|
||||
/**
|
||||
* The type of an {@link ApplicationCommandOption} object:
|
||||
* * SUB_COMMAND
|
||||
* * SUB_COMMAND_GROUP
|
||||
* * STRING
|
||||
* * INTEGER
|
||||
* * BOOLEAN
|
||||
* * USER
|
||||
* * CHANNEL
|
||||
* * ROLE
|
||||
* * MENTIONABLE
|
||||
* * NUMBER
|
||||
* @typedef {string} ApplicationCommandOptionType
|
||||
* @see {@link https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type}
|
||||
*/
|
||||
exports.ApplicationCommandOptionTypes = createEnum([
|
||||
null,
|
||||
'SUB_COMMAND',
|
||||
'SUB_COMMAND_GROUP',
|
||||
'STRING',
|
||||
'INTEGER',
|
||||
'BOOLEAN',
|
||||
'USER',
|
||||
'CHANNEL',
|
||||
'ROLE',
|
||||
'MENTIONABLE',
|
||||
'NUMBER',
|
||||
]);
|
||||
|
||||
/**
|
||||
* The type of an {@link ApplicationCommandPermissions} object:
|
||||
* * ROLE
|
||||
* * USER
|
||||
* @typedef {string} ApplicationCommandPermissionType
|
||||
* @see {@link https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permission-type}
|
||||
*/
|
||||
exports.ApplicationCommandPermissionTypes = createEnum([null, 'ROLE', 'USER']);
|
||||
|
||||
/**
|
||||
* The type of an {@link Interaction} object:
|
||||
* * PING
|
||||
* * APPLICATION_COMMAND
|
||||
* * MESSAGE_COMPONENT
|
||||
* * APPLICATION_COMMAND_AUTOCOMPLETE
|
||||
* @typedef {string} InteractionType
|
||||
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type}
|
||||
*/
|
||||
exports.InteractionTypes = createEnum([
|
||||
null,
|
||||
'PING',
|
||||
'APPLICATION_COMMAND',
|
||||
'MESSAGE_COMPONENT',
|
||||
'APPLICATION_COMMAND_AUTOCOMPLETE',
|
||||
]);
|
||||
|
||||
/**
|
||||
* The type of an interaction response:
|
||||
* * PONG
|
||||
* * CHANNEL_MESSAGE_WITH_SOURCE
|
||||
* * DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE
|
||||
* * DEFERRED_MESSAGE_UPDATE
|
||||
* * UPDATE_MESSAGE
|
||||
* * APPLICATION_COMMAND_AUTOCOMPLETE_RESULT
|
||||
* @typedef {string} InteractionResponseType
|
||||
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type}
|
||||
*/
|
||||
exports.InteractionResponseTypes = createEnum([
|
||||
null,
|
||||
'PONG',
|
||||
null,
|
||||
null,
|
||||
'CHANNEL_MESSAGE_WITH_SOURCE',
|
||||
'DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE',
|
||||
'DEFERRED_MESSAGE_UPDATE',
|
||||
'UPDATE_MESSAGE',
|
||||
'APPLICATION_COMMAND_AUTOCOMPLETE_RESULT',
|
||||
]);
|
||||
|
||||
/**
|
||||
* The type of a message component
|
||||
* * ACTION_ROW
|
||||
* * BUTTON
|
||||
* * SELECT_MENU
|
||||
* @typedef {string} MessageComponentType
|
||||
* @see {@link https://discord.com/developers/docs/interactions/message-components#component-object-component-types}
|
||||
*/
|
||||
exports.MessageComponentTypes = createEnum([null, 'ACTION_ROW', 'BUTTON', 'SELECT_MENU']);
|
||||
|
||||
/**
|
||||
* The style of a message button
|
||||
* * PRIMARY
|
||||
* * SECONDARY
|
||||
* * SUCCESS
|
||||
* * DANGER
|
||||
* * LINK
|
||||
* @typedef {string} MessageButtonStyle
|
||||
* @see {@link https://discord.com/developers/docs/interactions/message-components#button-object-button-styles}
|
||||
*/
|
||||
exports.MessageButtonStyles = createEnum([null, 'PRIMARY', 'SECONDARY', 'SUCCESS', 'DANGER', 'LINK']);
|
||||
|
||||
/**
|
||||
* The required MFA level for a guild
|
||||
* * NONE
|
||||
* * ELEVATED
|
||||
* @typedef {string} MFALevel
|
||||
* @see {@link https://discord.com/developers/docs/resources/guild#guild-object-mfa-level}
|
||||
*/
|
||||
exports.MFALevels = createEnum(['NONE', 'ELEVATED']);
|
||||
|
||||
/**
|
||||
* NSFW level of a Guild:
|
||||
* * DEFAULT
|
||||
* * EXPLICIT
|
||||
* * SAFE
|
||||
* * AGE_RESTRICTED
|
||||
* @typedef {string} NSFWLevel
|
||||
* @see {@link https://discord.com/developers/docs/resources/guild#guild-object-guild-nsfw-level}
|
||||
*/
|
||||
exports.NSFWLevels = createEnum(['DEFAULT', 'EXPLICIT', 'SAFE', 'AGE_RESTRICTED']);
|
||||
|
||||
/**
|
||||
* Privacy level of a {@link StageInstance} object:
|
||||
* * PUBLIC
|
||||
* * GUILD_ONLY
|
||||
* @typedef {string} PrivacyLevel
|
||||
* @see {@link https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-privacy-level}
|
||||
*/
|
||||
exports.PrivacyLevels = createEnum([null, 'PUBLIC', 'GUILD_ONLY']);
|
||||
|
||||
/**
|
||||
* Privacy level of a {@link GuildScheduledEvent} object:
|
||||
* * GUILD_ONLY
|
||||
* @typedef {string} GuildScheduledEventPrivacyLevel
|
||||
* @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-privacy-level}
|
||||
*/
|
||||
exports.GuildScheduledEventPrivacyLevels = createEnum([null, null, 'GUILD_ONLY']);
|
||||
|
||||
/**
|
||||
* The premium tier (Server Boost level) of a guild:
|
||||
* * NONE
|
||||
* * TIER_1
|
||||
* * TIER_2
|
||||
* * TIER_3
|
||||
* @typedef {string} PremiumTier
|
||||
* @see {@link https://discord.com/developers/docs/resources/guild#guild-object-premium-tier}
|
||||
*/
|
||||
exports.PremiumTiers = createEnum(['NONE', 'TIER_1', 'TIER_2', 'TIER_3']);
|
||||
|
||||
/**
|
||||
* The status of a {@link GuildScheduledEvent}:
|
||||
* * SCHEDULED
|
||||
* * ACTIVE
|
||||
* * COMPLETED
|
||||
* * CANCELED
|
||||
* @typedef {string} GuildScheduledEventStatus
|
||||
* @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status}
|
||||
*/
|
||||
exports.GuildScheduledEventStatuses = createEnum([null, 'SCHEDULED', 'ACTIVE', 'COMPLETED', 'CANCELED']);
|
||||
|
||||
/**
|
||||
* The entity type of a {@link GuildScheduledEvent}:
|
||||
* * NONE
|
||||
* * STAGE_INSTANCE
|
||||
* * VOICE
|
||||
* * EXTERNAL
|
||||
* @typedef {string} GuildScheduledEventEntityType
|
||||
* @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types}
|
||||
*/
|
||||
exports.GuildScheduledEventEntityTypes = createEnum([null, 'STAGE_INSTANCE', 'VOICE', 'EXTERNAL']);
|
||||
/* eslint-enable max-len */
|
||||
|
||||
function keyMirror(arr) {
|
||||
@@ -1178,37 +576,6 @@ function createEnum(keys) {
|
||||
|
||||
/**
|
||||
* @typedef {Object} Constants Constants that can be used in an enum or object-like way.
|
||||
* @property {ActivityType} ActivityTypes The type of an activity of a users presence.
|
||||
* @property {APIError} APIErrors An error encountered while performing an API request.
|
||||
* @property {ApplicationCommandOptionType} ApplicationCommandOptionTypes
|
||||
* The type of an {@link ApplicationCommandOption} object.
|
||||
* @property {ApplicationCommandPermissionType} ApplicationCommandPermissionTypes
|
||||
* The type of an {@link ApplicationCommandPermissions} object.
|
||||
* @property {ChannelType} ChannelTypes All available channel types.
|
||||
* @property {DefaultMessageNotificationLevel} DefaultMessageNotificationLevels
|
||||
* The value set for a guild's default message notifications.
|
||||
* @property {ExplicitContentFilterLevel} ExplicitContentFilterLevels
|
||||
* The value set for the explicit content filter levels for a guild.
|
||||
* @property {GuildScheduledEventStatus} GuildScheduledEventStatuses The status of a {@link GuildScheduledEvent} object.
|
||||
* @property {GuildScheduledEventEntityType} GuildScheduledEventEntityTypes The entity type of a
|
||||
* {@link GuildScheduledEvent} object.
|
||||
* @property {GuildScheduledEventPrivacyLevel} GuildScheduledEventPrivacyLevels Privacy level of a
|
||||
* {@link GuildScheduledEvent} object.
|
||||
* @property {InteractionResponseType} InteractionResponseTypes The type of an interaction response.
|
||||
* @property {InteractionType} InteractionTypes The type of an {@link Interaction} object.
|
||||
* @property {MembershipState} MembershipStates The value set for a team member's membership state.
|
||||
* @property {MessageButtonStyle} MessageButtonStyles The style of a message button.
|
||||
* @property {MessageComponentType} MessageComponentTypes The type of a message component.
|
||||
* @property {MFALevel} MFALevels The required MFA level for a guild.
|
||||
* @property {NSFWLevel} NSFWLevels NSFW level of a guild.
|
||||
* @property {OverwriteType} OverwriteTypes An overwrite type.
|
||||
* @property {PartialType} PartialTypes The type of Structure allowed to be a partial.
|
||||
* @property {PremiumTier} PremiumTiers The premium tier (Server Boost level) of a guild.
|
||||
* @property {PrivacyLevel} PrivacyLevels Privacy level of a {@link StageInstance} object.
|
||||
* @property {Status} Status The available statuses of the client.
|
||||
* @property {StickerFormatType} StickerFormatTypes The value set for a sticker's format type.
|
||||
* @property {StickerType} StickerTypes The value set for a sticker's type.
|
||||
* @property {VerificationLevel} VerificationLevels The value set for the verification levels for a guild.
|
||||
* @property {WebhookType} WebhookTypes The value set for a webhook's type.
|
||||
* @property {WSEventType} WSEvents The type of a WebSocket message event.
|
||||
*/
|
||||
|
||||
198
packages/discord.js/typings/enums.d.ts
vendored
198
packages/discord.js/typings/enums.d.ts
vendored
@@ -1,198 +0,0 @@
|
||||
// These are enums that are used in the typings file but do not exist as actual exported values. To prevent them from
|
||||
// showing up in an editor, they are imported from here instead of exporting them there directly.
|
||||
|
||||
export const enum ActivityTypes {
|
||||
PLAYING = 0,
|
||||
STREAMING = 1,
|
||||
LISTENING = 2,
|
||||
WATCHING = 3,
|
||||
CUSTOM = 4,
|
||||
COMPETING = 5,
|
||||
}
|
||||
|
||||
export const enum ApplicationCommandTypes {
|
||||
CHAT_INPUT = 1,
|
||||
USER = 2,
|
||||
MESSAGE = 3,
|
||||
}
|
||||
|
||||
export const enum ApplicationCommandOptionTypes {
|
||||
SUB_COMMAND = 1,
|
||||
SUB_COMMAND_GROUP = 2,
|
||||
STRING = 3,
|
||||
INTEGER = 4,
|
||||
BOOLEAN = 5,
|
||||
USER = 6,
|
||||
CHANNEL = 7,
|
||||
ROLE = 8,
|
||||
MENTIONABLE = 9,
|
||||
NUMBER = 10,
|
||||
}
|
||||
|
||||
export const enum ApplicationCommandPermissionTypes {
|
||||
ROLE = 1,
|
||||
USER = 2,
|
||||
}
|
||||
|
||||
export const enum ChannelTypes {
|
||||
GUILD_TEXT = 0,
|
||||
DM = 1,
|
||||
GUILD_VOICE = 2,
|
||||
GROUP_DM = 3,
|
||||
GUILD_CATEGORY = 4,
|
||||
GUILD_NEWS = 5,
|
||||
GUILD_STORE = 6,
|
||||
UNKNOWN = 7,
|
||||
GUILD_NEWS_THREAD = 10,
|
||||
GUILD_PUBLIC_THREAD = 11,
|
||||
GUILD_PRIVATE_THREAD = 12,
|
||||
GUILD_STAGE_VOICE = 13,
|
||||
}
|
||||
|
||||
export const enum MessageTypes {
|
||||
DEFAULT,
|
||||
RECIPIENT_ADD,
|
||||
RECIPIENT_REMOVE,
|
||||
CALL,
|
||||
CHANNEL_NAME_CHANGE,
|
||||
CHANNEL_ICON_CHANGE,
|
||||
CHANNEL_PINNED_MESSAGE,
|
||||
GUILD_MEMBER_JOIN,
|
||||
USER_PREMIUM_GUILD_SUBSCRIPTION,
|
||||
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1,
|
||||
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2,
|
||||
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3,
|
||||
CHANNEL_FOLLOW_ADD,
|
||||
GUILD_DISCOVERY_DISQUALIFIED = 14,
|
||||
GUILD_DISCOVERY_REQUALIFIED,
|
||||
GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING,
|
||||
GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING,
|
||||
THREAD_CREATED,
|
||||
REPLY,
|
||||
CHAT_INPUT_COMMAND,
|
||||
THREAD_STARTER_MESSAGE,
|
||||
GUILD_INVITE_REMINDER,
|
||||
CONTEXT_MENU_COMMAND,
|
||||
}
|
||||
|
||||
export const enum DefaultMessageNotificationLevels {
|
||||
ALL_MESSAGES = 0,
|
||||
ONLY_MENTIONS = 1,
|
||||
}
|
||||
|
||||
export const enum ExplicitContentFilterLevels {
|
||||
DISABLED = 0,
|
||||
MEMBERS_WITHOUT_ROLES = 1,
|
||||
ALL_MEMBERS = 2,
|
||||
}
|
||||
|
||||
export const enum GuildScheduledEventEntityTypes {
|
||||
STAGE_INSTANCE = 1,
|
||||
VOICE = 2,
|
||||
EXTERNAL = 3,
|
||||
}
|
||||
|
||||
export const enum GuildScheduledEventPrivacyLevels {
|
||||
GUILD_ONLY = 2,
|
||||
}
|
||||
|
||||
export const enum GuildScheduledEventStatuses {
|
||||
SCHEDULED = 1,
|
||||
ACTIVE = 2,
|
||||
COMPLETED = 3,
|
||||
CANCELED = 4,
|
||||
}
|
||||
|
||||
export const enum InteractionResponseTypes {
|
||||
PONG = 1,
|
||||
CHANNEL_MESSAGE_WITH_SOURCE = 4,
|
||||
DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE = 5,
|
||||
DEFERRED_MESSAGE_UPDATE = 6,
|
||||
UPDATE_MESSAGE = 7,
|
||||
APPLICATION_COMMAND_AUTOCOMPLETE_RESULT = 8,
|
||||
}
|
||||
|
||||
export const enum InteractionTypes {
|
||||
PING = 1,
|
||||
APPLICATION_COMMAND = 2,
|
||||
MESSAGE_COMPONENT = 3,
|
||||
APPLICATION_COMMAND_AUTOCOMPLETE = 4,
|
||||
}
|
||||
|
||||
export const enum InviteTargetType {
|
||||
STREAM = 1,
|
||||
EMBEDDED_APPLICATION = 2,
|
||||
}
|
||||
|
||||
export const enum MembershipStates {
|
||||
INVITED = 1,
|
||||
ACCEPTED = 2,
|
||||
}
|
||||
|
||||
export const enum MessageButtonStyles {
|
||||
PRIMARY = 1,
|
||||
SECONDARY = 2,
|
||||
SUCCESS = 3,
|
||||
DANGER = 4,
|
||||
LINK = 5,
|
||||
}
|
||||
|
||||
export const enum MessageComponentTypes {
|
||||
ACTION_ROW = 1,
|
||||
BUTTON = 2,
|
||||
SELECT_MENU = 3,
|
||||
}
|
||||
|
||||
export const enum MFALevels {
|
||||
NONE = 0,
|
||||
ELEVATED = 1,
|
||||
}
|
||||
|
||||
export const enum NSFWLevels {
|
||||
DEFAULT = 0,
|
||||
EXPLICIT = 1,
|
||||
SAFE = 2,
|
||||
AGE_RESTRICTED = 3,
|
||||
}
|
||||
|
||||
export const enum OverwriteTypes {
|
||||
role = 0,
|
||||
member = 1,
|
||||
}
|
||||
|
||||
export const enum PremiumTiers {
|
||||
NONE = 0,
|
||||
TIER_1 = 1,
|
||||
TIER_2 = 2,
|
||||
TIER_3 = 3,
|
||||
}
|
||||
|
||||
export const enum PrivacyLevels {
|
||||
PUBLIC = 1,
|
||||
GUILD_ONLY = 2,
|
||||
}
|
||||
|
||||
export const enum StickerFormatTypes {
|
||||
PNG = 1,
|
||||
APNG = 2,
|
||||
LOTTIE = 3,
|
||||
}
|
||||
|
||||
export const enum StickerTypes {
|
||||
STANDARD = 1,
|
||||
GUILD = 2,
|
||||
}
|
||||
|
||||
export const enum VerificationLevels {
|
||||
NONE = 0,
|
||||
LOW = 1,
|
||||
MEDIUM = 2,
|
||||
HIGH = 3,
|
||||
VERY_HIGH = 4,
|
||||
}
|
||||
|
||||
export const enum WebhookTypes {
|
||||
Incoming = 1,
|
||||
'Channel Follower' = 2,
|
||||
Application = 3,
|
||||
}
|
||||
875
packages/discord.js/typings/index.d.ts
vendored
875
packages/discord.js/typings/index.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,7 @@ import type {
|
||||
APIRole,
|
||||
APIButtonComponent,
|
||||
APISelectMenuComponent,
|
||||
ApplicationCommandOptionType,
|
||||
} from 'discord-api-types/v9';
|
||||
import { AuditLogEvent } from 'discord-api-types/v9';
|
||||
import {
|
||||
@@ -91,7 +92,6 @@ import {
|
||||
MessageSelectMenu,
|
||||
PartialDMChannel,
|
||||
} from '.';
|
||||
import type { ApplicationCommandOptionTypes } from './enums';
|
||||
import { expectAssignable, expectDeprecated, expectNotAssignable, expectNotType, expectType } from 'tsd';
|
||||
|
||||
// Test type transformation:
|
||||
@@ -144,7 +144,7 @@ client.on('ready', async () => {
|
||||
await globalPermissionsManager?.add({
|
||||
command: globalCommandId,
|
||||
guild: testGuildId,
|
||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
||||
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||
});
|
||||
await globalPermissionsManager?.has({ command: globalCommandId, guild: testGuildId, permissionId: testGuildId });
|
||||
await globalPermissionsManager?.fetch({ guild: testGuildId });
|
||||
@@ -160,17 +160,17 @@ client.on('ready', async () => {
|
||||
await globalPermissionsManager?.set({
|
||||
command: globalCommandId,
|
||||
guild: testGuildId,
|
||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
||||
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||
});
|
||||
await globalPermissionsManager?.set({
|
||||
guild: testGuildId,
|
||||
fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }],
|
||||
fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'Role', id: testGuildId, permission: true }] }],
|
||||
});
|
||||
|
||||
// @ts-expect-error
|
||||
await globalPermissionsManager?.add({
|
||||
command: globalCommandId,
|
||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
||||
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||
});
|
||||
// @ts-expect-error
|
||||
await globalPermissionsManager?.has({ command: globalCommandId, permissionId: testGuildId });
|
||||
@@ -187,23 +187,23 @@ client.on('ready', async () => {
|
||||
// @ts-expect-error
|
||||
await globalPermissionsManager?.set({
|
||||
command: globalCommandId,
|
||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
||||
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||
});
|
||||
// @ts-expect-error
|
||||
await globalPermissionsManager?.set({
|
||||
fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }],
|
||||
fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'Role', id: testGuildId, permission: true }] }],
|
||||
});
|
||||
// @ts-expect-error
|
||||
await globalPermissionsManager?.set({
|
||||
command: globalCommandId,
|
||||
guild: testGuildId,
|
||||
fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }],
|
||||
fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'Role', id: testGuildId, permission: true }] }],
|
||||
});
|
||||
|
||||
// @ts-expect-error
|
||||
await globalPermissionsManager?.add({
|
||||
guild: testGuildId,
|
||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
||||
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||
});
|
||||
// @ts-expect-error
|
||||
await globalPermissionsManager?.has({ guild: testGuildId, permissionId: testGuildId });
|
||||
@@ -216,13 +216,13 @@ client.on('ready', async () => {
|
||||
// @ts-expect-error
|
||||
await globalPermissionsManager?.set({
|
||||
guild: testGuildId,
|
||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
||||
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||
});
|
||||
|
||||
// Permissions from guild manager
|
||||
await guildPermissionsManager?.add({
|
||||
command: globalCommandId,
|
||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
||||
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||
});
|
||||
await guildPermissionsManager?.has({ command: globalCommandId, permissionId: testGuildId });
|
||||
await guildPermissionsManager?.fetch({});
|
||||
@@ -232,17 +232,17 @@ client.on('ready', async () => {
|
||||
await guildPermissionsManager?.remove({ command: globalCommandId, roles: [testGuildId], users: [testUserId] });
|
||||
await guildPermissionsManager?.set({
|
||||
command: globalCommandId,
|
||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
||||
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||
});
|
||||
await guildPermissionsManager?.set({
|
||||
fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }],
|
||||
fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'Role', id: testGuildId, permission: true }] }],
|
||||
});
|
||||
|
||||
await guildPermissionsManager?.add({
|
||||
command: globalCommandId,
|
||||
// @ts-expect-error
|
||||
guild: testGuildId,
|
||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
||||
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||
});
|
||||
// @ts-expect-error
|
||||
await guildPermissionsManager?.has({ command: globalCommandId, guild: testGuildId, permissionId: testGuildId });
|
||||
@@ -265,16 +265,16 @@ client.on('ready', async () => {
|
||||
await guildPermissionsManager?.set({
|
||||
command: globalCommandId,
|
||||
guild: testGuildId,
|
||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
||||
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||
});
|
||||
await guildPermissionsManager?.set({
|
||||
// @ts-expect-error
|
||||
guild: testGuildId,
|
||||
fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }],
|
||||
fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'Role', id: testGuildId, permission: true }] }],
|
||||
});
|
||||
|
||||
// @ts-expect-error
|
||||
await guildPermissionsManager?.add({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] });
|
||||
await guildPermissionsManager?.add({ permissions: [{ type: 'Role', id: testGuildId, permission: true }] });
|
||||
// @ts-expect-error
|
||||
await guildPermissionsManager?.has({ permissionId: testGuildId });
|
||||
// @ts-expect-error
|
||||
@@ -284,17 +284,17 @@ client.on('ready', async () => {
|
||||
// @ts-expect-error
|
||||
await guildPermissionsManager?.remove({ roles: [testGuildId], users: [testUserId] });
|
||||
// @ts-expect-error
|
||||
await guildPermissionsManager?.set({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] });
|
||||
await guildPermissionsManager?.set({ permissions: [{ type: 'Role', id: testGuildId, permission: true }] });
|
||||
// @ts-expect-error
|
||||
await guildPermissionsManager?.set({
|
||||
command: globalCommandId,
|
||||
fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }],
|
||||
fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'Role', id: testGuildId, permission: true }] }],
|
||||
});
|
||||
|
||||
// Permissions from cached global ApplicationCommand
|
||||
await globalCommand?.permissions.add({
|
||||
guild: testGuildId,
|
||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
||||
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||
});
|
||||
await globalCommand?.permissions.has({ guild: testGuildId, permissionId: testGuildId });
|
||||
await globalCommand?.permissions.fetch({ guild: testGuildId });
|
||||
@@ -303,14 +303,14 @@ client.on('ready', async () => {
|
||||
await globalCommand?.permissions.remove({ guild: testGuildId, roles: [testGuildId], users: [testUserId] });
|
||||
await globalCommand?.permissions.set({
|
||||
guild: testGuildId,
|
||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
||||
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||
});
|
||||
|
||||
await globalCommand?.permissions.add({
|
||||
// @ts-expect-error
|
||||
command: globalCommandId,
|
||||
guild: testGuildId,
|
||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
||||
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||
});
|
||||
// @ts-expect-error
|
||||
await globalCommand?.permissions.has({ command: globalCommandId, guild: testGuildId, permissionId: testGuildId });
|
||||
@@ -331,11 +331,11 @@ client.on('ready', async () => {
|
||||
// @ts-expect-error
|
||||
command: globalCommandId,
|
||||
guild: testGuildId,
|
||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
||||
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||
});
|
||||
|
||||
// @ts-expect-error
|
||||
await globalCommand?.permissions.add({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] });
|
||||
await globalCommand?.permissions.add({ permissions: [{ type: 'Role', id: testGuildId, permission: true }] });
|
||||
// @ts-expect-error
|
||||
await globalCommand?.permissions.has({ permissionId: testGuildId });
|
||||
// @ts-expect-error
|
||||
@@ -347,21 +347,21 @@ client.on('ready', async () => {
|
||||
// @ts-expect-error
|
||||
await globalCommand?.permissions.remove({ roles: [testGuildId], users: [testUserId] });
|
||||
// @ts-expect-error
|
||||
await globalCommand?.permissions.set({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] });
|
||||
await globalCommand?.permissions.set({ permissions: [{ type: 'Role', id: testGuildId, permission: true }] });
|
||||
|
||||
// Permissions from cached guild ApplicationCommand
|
||||
await guildCommandFromGlobal?.permissions.add({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] });
|
||||
await guildCommandFromGlobal?.permissions.add({ permissions: [{ type: 'Role', id: testGuildId, permission: true }] });
|
||||
await guildCommandFromGlobal?.permissions.has({ permissionId: testGuildId });
|
||||
await guildCommandFromGlobal?.permissions.fetch({});
|
||||
await guildCommandFromGlobal?.permissions.remove({ roles: [testGuildId] });
|
||||
await guildCommandFromGlobal?.permissions.remove({ users: [testUserId] });
|
||||
await guildCommandFromGlobal?.permissions.remove({ roles: [testGuildId], users: [testUserId] });
|
||||
await guildCommandFromGlobal?.permissions.set({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] });
|
||||
await guildCommandFromGlobal?.permissions.set({ permissions: [{ type: 'Role', id: testGuildId, permission: true }] });
|
||||
|
||||
await guildCommandFromGlobal?.permissions.add({
|
||||
// @ts-expect-error
|
||||
command: globalCommandId,
|
||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
||||
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||
});
|
||||
// @ts-expect-error
|
||||
await guildCommandFromGlobal?.permissions.has({ command: guildCommandId, permissionId: testGuildId });
|
||||
@@ -378,13 +378,13 @@ client.on('ready', async () => {
|
||||
await guildCommandFromGlobal?.permissions.set({
|
||||
// @ts-expect-error
|
||||
command: guildCommandId,
|
||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
||||
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||
});
|
||||
|
||||
await guildCommandFromGlobal?.permissions.add({
|
||||
// @ts-expect-error
|
||||
guild: testGuildId,
|
||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
||||
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||
});
|
||||
// @ts-expect-error
|
||||
await guildCommandFromGlobal?.permissions.has({ guild: testGuildId, permissionId: testGuildId });
|
||||
@@ -397,21 +397,21 @@ client.on('ready', async () => {
|
||||
await guildCommandFromGlobal?.permissions.set({
|
||||
// @ts-expect-error
|
||||
guild: testGuildId,
|
||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
||||
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||
});
|
||||
|
||||
await guildCommandFromGuild?.permissions.add({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] });
|
||||
await guildCommandFromGuild?.permissions.add({ permissions: [{ type: 'Role', id: testGuildId, permission: true }] });
|
||||
await guildCommandFromGuild?.permissions.has({ permissionId: testGuildId });
|
||||
await guildCommandFromGuild?.permissions.fetch({});
|
||||
await guildCommandFromGuild?.permissions.remove({ roles: [testGuildId] });
|
||||
await guildCommandFromGuild?.permissions.remove({ users: [testUserId] });
|
||||
await guildCommandFromGuild?.permissions.remove({ roles: [testGuildId], users: [testUserId] });
|
||||
await guildCommandFromGuild?.permissions.set({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] });
|
||||
await guildCommandFromGuild?.permissions.set({ permissions: [{ type: 'Role', id: testGuildId, permission: true }] });
|
||||
|
||||
await guildCommandFromGuild?.permissions.add({
|
||||
// @ts-expect-error
|
||||
command: globalCommandId,
|
||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
||||
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||
});
|
||||
// @ts-expect-error
|
||||
await guildCommandFromGuild?.permissions.has({ command: guildCommandId, permissionId: testGuildId });
|
||||
@@ -428,13 +428,13 @@ client.on('ready', async () => {
|
||||
await guildCommandFromGuild?.permissions.set({
|
||||
// @ts-expect-error
|
||||
command: guildCommandId,
|
||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
||||
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||
});
|
||||
|
||||
await guildCommandFromGuild?.permissions.add({
|
||||
// @ts-expect-error
|
||||
guild: testGuildId,
|
||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
||||
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||
});
|
||||
// @ts-expect-error
|
||||
await guildCommandFromGuild?.permissions.has({ guild: testGuildId, permissionId: testGuildId });
|
||||
@@ -447,7 +447,7 @@ client.on('ready', async () => {
|
||||
await guildCommandFromGuild?.permissions.set({
|
||||
// @ts-expect-error
|
||||
guild: testGuildId,
|
||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
||||
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||
});
|
||||
|
||||
client.application?.commands.permissions.set({
|
||||
@@ -526,11 +526,11 @@ client.on('messageCreate', async message => {
|
||||
|
||||
if (message.inGuild()) {
|
||||
expectAssignable<Message<true>>(message);
|
||||
const component = await message.awaitMessageComponent({ componentType: 'BUTTON' });
|
||||
const component = await message.awaitMessageComponent({ componentType: 'Button' });
|
||||
expectType<ButtonInteraction<'cached'>>(component);
|
||||
expectType<Message<true>>(await component.reply({ fetchReply: true }));
|
||||
|
||||
const buttonCollector = message.createMessageComponentCollector({ componentType: 'BUTTON' });
|
||||
const buttonCollector = message.createMessageComponentCollector({ componentType: 'Button' });
|
||||
expectType<InteractionCollector<ButtonInteraction<'cached'>>>(buttonCollector);
|
||||
expectAssignable<(test: ButtonInteraction<'cached'>) => boolean | Promise<boolean>>(buttonCollector.filter);
|
||||
expectType<GuildTextBasedChannel>(message.channel);
|
||||
@@ -549,15 +549,15 @@ client.on('messageCreate', async message => {
|
||||
// Check collector creations.
|
||||
|
||||
// Verify that buttons interactions are inferred.
|
||||
const buttonCollector = message.createMessageComponentCollector({ componentType: 'BUTTON' });
|
||||
expectAssignable<Promise<ButtonInteraction>>(message.awaitMessageComponent({ componentType: 'BUTTON' }));
|
||||
expectAssignable<Promise<ButtonInteraction>>(channel.awaitMessageComponent({ componentType: 'BUTTON' }));
|
||||
const buttonCollector = message.createMessageComponentCollector({ componentType: 'Button' });
|
||||
expectAssignable<Promise<ButtonInteraction>>(message.awaitMessageComponent({ componentType: 'Button' }));
|
||||
expectAssignable<Promise<ButtonInteraction>>(channel.awaitMessageComponent({ componentType: 'Button' }));
|
||||
expectAssignable<InteractionCollector<ButtonInteraction>>(buttonCollector);
|
||||
|
||||
// Verify that select menus interaction are inferred.
|
||||
const selectMenuCollector = message.createMessageComponentCollector({ componentType: 'SELECT_MENU' });
|
||||
expectAssignable<Promise<SelectMenuInteraction>>(message.awaitMessageComponent({ componentType: 'SELECT_MENU' }));
|
||||
expectAssignable<Promise<SelectMenuInteraction>>(channel.awaitMessageComponent({ componentType: 'SELECT_MENU' }));
|
||||
const selectMenuCollector = message.createMessageComponentCollector({ componentType: 'SelectMenu' });
|
||||
expectAssignable<Promise<SelectMenuInteraction>>(message.awaitMessageComponent({ componentType: 'SelectMenu' }));
|
||||
expectAssignable<Promise<SelectMenuInteraction>>(channel.awaitMessageComponent({ componentType: 'SelectMenu' }));
|
||||
expectAssignable<InteractionCollector<SelectMenuInteraction>>(selectMenuCollector);
|
||||
|
||||
// Verify that message component interactions are default collected types.
|
||||
@@ -586,7 +586,7 @@ client.on('messageCreate', async message => {
|
||||
});
|
||||
|
||||
message.createMessageComponentCollector({
|
||||
componentType: 'BUTTON',
|
||||
componentType: 'Button',
|
||||
filter: i => {
|
||||
expectType<ButtonInteraction>(i);
|
||||
return true;
|
||||
@@ -594,7 +594,7 @@ client.on('messageCreate', async message => {
|
||||
});
|
||||
|
||||
message.createMessageComponentCollector({
|
||||
componentType: 'SELECT_MENU',
|
||||
componentType: 'SelectMenu',
|
||||
filter: i => {
|
||||
expectType<SelectMenuInteraction>(i);
|
||||
return true;
|
||||
@@ -609,7 +609,7 @@ client.on('messageCreate', async message => {
|
||||
});
|
||||
|
||||
message.awaitMessageComponent({
|
||||
componentType: 'BUTTON',
|
||||
componentType: 'Button',
|
||||
filter: i => {
|
||||
expectType<ButtonInteraction>(i);
|
||||
return true;
|
||||
@@ -617,7 +617,7 @@ client.on('messageCreate', async message => {
|
||||
});
|
||||
|
||||
message.awaitMessageComponent({
|
||||
componentType: 'SELECT_MENU',
|
||||
componentType: 'SelectMenu',
|
||||
filter: i => {
|
||||
expectType<SelectMenuInteraction>(i);
|
||||
return true;
|
||||
@@ -645,7 +645,7 @@ client.on('messageCreate', async message => {
|
||||
});
|
||||
|
||||
channel.awaitMessageComponent({
|
||||
componentType: 'BUTTON',
|
||||
componentType: 'Button',
|
||||
filter: i => {
|
||||
expectType<ButtonInteraction<'cached'>>(i);
|
||||
return true;
|
||||
@@ -653,7 +653,7 @@ client.on('messageCreate', async message => {
|
||||
});
|
||||
|
||||
channel.awaitMessageComponent({
|
||||
componentType: 'SELECT_MENU',
|
||||
componentType: 'SelectMenu',
|
||||
filter: i => {
|
||||
expectType<SelectMenuInteraction<'cached'>>(i);
|
||||
return true;
|
||||
@@ -772,8 +772,8 @@ expectType<Message | null>(newsChannel.lastMessage);
|
||||
expectType<Message | null>(textChannel.lastMessage);
|
||||
|
||||
expectDeprecated(storeChannel.clone());
|
||||
expectDeprecated(categoryChannel.createChannel('Store', { type: 'GUILD_STORE' }));
|
||||
expectDeprecated(guild.channels.create('Store', { type: 'GUILD_STORE' }));
|
||||
expectDeprecated(categoryChannel.createChannel('Store', { type: 'GuildStore' }));
|
||||
expectDeprecated(guild.channels.create('Store', { type: 'GuildStore' }));
|
||||
|
||||
notPropertyOf(user, 'lastMessage');
|
||||
notPropertyOf(user, 'lastMessageId');
|
||||
@@ -844,9 +844,7 @@ declare const applicationNonChoiceOptionData: ApplicationCommandOptionData & {
|
||||
|
||||
declare const applicationSubGroupCommandData: ApplicationCommandSubGroupData;
|
||||
{
|
||||
expectType<'SUB_COMMAND_GROUP' | ApplicationCommandOptionTypes.SUB_COMMAND_GROUP>(
|
||||
applicationSubGroupCommandData.type,
|
||||
);
|
||||
expectType<'SubcommandGroup' | ApplicationCommandOptionType.SubcommandGroup>(applicationSubGroupCommandData.type);
|
||||
expectType<ApplicationCommandSubCommandData[] | undefined>(applicationSubGroupCommandData.options);
|
||||
}
|
||||
|
||||
@@ -857,25 +855,25 @@ expectType<Promise<ApplicationCommand>>(guildApplicationCommandManager.fetch('0'
|
||||
|
||||
declare const categoryChannel: CategoryChannel;
|
||||
{
|
||||
expectType<Promise<VoiceChannel>>(categoryChannel.createChannel('name', { type: 'GUILD_VOICE' }));
|
||||
expectType<Promise<TextChannel>>(categoryChannel.createChannel('name', { type: 'GUILD_TEXT' }));
|
||||
expectType<Promise<NewsChannel>>(categoryChannel.createChannel('name', { type: 'GUILD_NEWS' }));
|
||||
expectType<Promise<StoreChannel>>(categoryChannel.createChannel('name', { type: 'GUILD_STORE' }));
|
||||
expectType<Promise<StageChannel>>(categoryChannel.createChannel('name', { type: 'GUILD_STAGE_VOICE' }));
|
||||
expectType<Promise<TextChannel>>(categoryChannel.createChannel('name', {}));
|
||||
expectType<Promise<TextChannel>>(categoryChannel.createChannel('name'));
|
||||
expectType<Promise<VoiceChannel>>(categoryChannel.createChannel('name', { type: 'GuildVoice' }));
|
||||
expectType<Promise<TextChannel>>(categoryChannel.createChannel('name', { type: 'GuildText' }));
|
||||
expectType<Promise<NewsChannel>>(categoryChannel.createChannel('name', { type: 'GuildNews' }));
|
||||
expectDeprecated(categoryChannel.createChannel('name', { type: 'GuildStore' }));
|
||||
expectType<Promise<StageChannel>>(categoryChannel.createChannel('name', { type: 'GuildStageVoice' }));
|
||||
expectType<Promise<Exclude<NonThreadGuildBasedChannel, CategoryChannel>>>(categoryChannel.createChannel('name', {}));
|
||||
expectType<Promise<Exclude<NonThreadGuildBasedChannel, CategoryChannel>>>(categoryChannel.createChannel('name'));
|
||||
}
|
||||
|
||||
declare const guildChannelManager: GuildChannelManager;
|
||||
{
|
||||
type AnyChannel = TextChannel | VoiceChannel | CategoryChannel | NewsChannel | StoreChannel | StageChannel;
|
||||
|
||||
expectType<Promise<VoiceChannel>>(guildChannelManager.create('name', { type: 'GUILD_VOICE' }));
|
||||
expectType<Promise<CategoryChannel>>(guildChannelManager.create('name', { type: 'GUILD_CATEGORY' }));
|
||||
expectType<Promise<TextChannel>>(guildChannelManager.create('name', { type: 'GUILD_TEXT' }));
|
||||
expectType<Promise<NewsChannel>>(guildChannelManager.create('name', { type: 'GUILD_NEWS' }));
|
||||
expectType<Promise<StoreChannel>>(guildChannelManager.create('name', { type: 'GUILD_STORE' }));
|
||||
expectType<Promise<StageChannel>>(guildChannelManager.create('name', { type: 'GUILD_STAGE_VOICE' }));
|
||||
expectType<Promise<VoiceChannel>>(guildChannelManager.create('name', { type: 'GuildVoice' }));
|
||||
expectType<Promise<CategoryChannel>>(guildChannelManager.create('name', { type: 'GuildCategory' }));
|
||||
expectType<Promise<TextChannel>>(guildChannelManager.create('name', { type: 'GuildText' }));
|
||||
expectType<Promise<NewsChannel>>(guildChannelManager.create('name', { type: 'GuildNews' }));
|
||||
expectType<Promise<StoreChannel>>(guildChannelManager.create('name', { type: 'GuildStore' }));
|
||||
expectType<Promise<StageChannel>>(guildChannelManager.create('name', { type: 'GuildStageVoice' }));
|
||||
|
||||
expectType<Promise<Collection<Snowflake, AnyChannel>>>(guildChannelManager.fetch());
|
||||
expectType<Promise<Collection<Snowflake, AnyChannel>>>(guildChannelManager.fetch(undefined, {}));
|
||||
@@ -1080,7 +1078,7 @@ client.on('interactionCreate', async interaction => {
|
||||
expectType<APIRole>(interaction.options.getRole('test', true));
|
||||
} else if (interaction.inCachedGuild()) {
|
||||
const msg = await interaction.reply({ fetchReply: true });
|
||||
const btn = await msg.awaitMessageComponent({ componentType: 'BUTTON' });
|
||||
const btn = await msg.awaitMessageComponent({ componentType: 'Button' });
|
||||
|
||||
expectType<Message<true>>(msg);
|
||||
expectType<ButtonInteraction<'cached'>>(btn);
|
||||
@@ -1167,79 +1165,79 @@ collector.on('end', (collection, reason) => {
|
||||
expectType<Promise<number | null>>(shard.eval(c => c.readyTimestamp));
|
||||
|
||||
// Test audit logs
|
||||
expectType<Promise<GuildAuditLogs<'MEMBER_KICK'>>>(guild.fetchAuditLogs({ type: 'MEMBER_KICK' }));
|
||||
expectType<Promise<GuildAuditLogs<'MemberKick'>>>(guild.fetchAuditLogs({ type: 'MemberKick' }));
|
||||
expectAssignable<Promise<GuildAuditLogs<AuditLogEvent.MemberKick>>>(
|
||||
guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.MEMBER_KICK }),
|
||||
guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.MemberKick }),
|
||||
);
|
||||
expectType<Promise<GuildAuditLogs<AuditLogEvent.MemberKick>>>(guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick }));
|
||||
|
||||
expectType<Promise<GuildAuditLogs<'CHANNEL_CREATE'>>>(guild.fetchAuditLogs({ type: 'CHANNEL_CREATE' }));
|
||||
expectType<Promise<GuildAuditLogs<'ChannelCreate'>>>(guild.fetchAuditLogs({ type: 'ChannelCreate' }));
|
||||
expectAssignable<Promise<GuildAuditLogs<AuditLogEvent.ChannelCreate>>>(
|
||||
guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.CHANNEL_CREATE }),
|
||||
guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.ChannelCreate }),
|
||||
);
|
||||
expectType<Promise<GuildAuditLogs<AuditLogEvent.ChannelCreate>>>(
|
||||
guild.fetchAuditLogs({ type: AuditLogEvent.ChannelCreate }),
|
||||
);
|
||||
|
||||
expectType<Promise<GuildAuditLogs<'INTEGRATION_UPDATE'>>>(guild.fetchAuditLogs({ type: 'INTEGRATION_UPDATE' }));
|
||||
expectType<Promise<GuildAuditLogs<'IntegrationUpdate'>>>(guild.fetchAuditLogs({ type: 'IntegrationUpdate' }));
|
||||
expectAssignable<Promise<GuildAuditLogs<AuditLogEvent.IntegrationUpdate>>>(
|
||||
guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.INTEGRATION_UPDATE }),
|
||||
guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.IntegrationUpdate }),
|
||||
);
|
||||
expectType<Promise<GuildAuditLogs<AuditLogEvent.IntegrationUpdate>>>(
|
||||
guild.fetchAuditLogs({ type: AuditLogEvent.IntegrationUpdate }),
|
||||
);
|
||||
|
||||
expectType<Promise<GuildAuditLogs<'ALL'>>>(guild.fetchAuditLogs({ type: 'ALL' }));
|
||||
expectType<Promise<GuildAuditLogs<null>>>(guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.ALL }));
|
||||
expectType<Promise<GuildAuditLogs<'ALL'>>>(guild.fetchAuditLogs());
|
||||
expectType<Promise<GuildAuditLogs<'All'>>>(guild.fetchAuditLogs({ type: 'All' }));
|
||||
expectType<Promise<GuildAuditLogs<null>>>(guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.All }));
|
||||
expectType<Promise<GuildAuditLogs<'All'>>>(guild.fetchAuditLogs());
|
||||
|
||||
expectType<Promise<GuildAuditLogsEntry<'MEMBER_KICK', 'MEMBER_KICK', 'DELETE', 'USER'> | undefined>>(
|
||||
guild.fetchAuditLogs({ type: 'MEMBER_KICK' }).then(al => al.entries.first()),
|
||||
expectType<Promise<GuildAuditLogsEntry<'MemberKick', 'MemberKick', 'Delete', 'User'> | undefined>>(
|
||||
guild.fetchAuditLogs({ type: 'MemberKick' }).then(al => al.entries.first()),
|
||||
);
|
||||
expectType<Promise<GuildAuditLogsEntry<'MEMBER_KICK', 'MEMBER_KICK', 'DELETE', 'USER'> | undefined>>(
|
||||
guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.MEMBER_KICK }).then(al => al.entries.first()),
|
||||
expectType<Promise<GuildAuditLogsEntry<'MemberKick', 'MemberKick', 'Delete', 'User'> | undefined>>(
|
||||
guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.MemberKick }).then(al => al.entries.first()),
|
||||
);
|
||||
expectAssignable<Promise<GuildAuditLogsEntry<'MEMBER_KICK', 'MEMBER_KICK', 'DELETE', 'USER'> | undefined>>(
|
||||
expectAssignable<Promise<GuildAuditLogsEntry<'MemberKick', 'MemberKick', 'Delete', 'User'> | undefined>>(
|
||||
guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick }).then(al => al.entries.first()),
|
||||
);
|
||||
|
||||
expectType<Promise<GuildAuditLogsEntry<'ALL', 'ALL', 'ALL', 'UNKNOWN'> | undefined>>(
|
||||
guild.fetchAuditLogs({ type: 'ALL' }).then(al => al.entries.first()),
|
||||
expectType<Promise<GuildAuditLogsEntry<'All', 'All', 'All', 'Unknown'> | undefined>>(
|
||||
guild.fetchAuditLogs({ type: 'All' }).then(al => al.entries.first()),
|
||||
);
|
||||
expectType<Promise<GuildAuditLogsEntry<'ALL', 'ALL', 'ALL', 'UNKNOWN'> | undefined>>(
|
||||
guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.ALL }).then(al => al.entries.first()),
|
||||
expectType<Promise<GuildAuditLogsEntry<'All', 'All', 'All', 'Unknown'> | undefined>>(
|
||||
guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.All }).then(al => al.entries.first()),
|
||||
);
|
||||
expectType<Promise<GuildAuditLogsEntry<'ALL', 'ALL', 'ALL', 'UNKNOWN'> | undefined>>(
|
||||
expectType<Promise<GuildAuditLogsEntry<'All', 'All', 'All', 'Unknown'> | undefined>>(
|
||||
guild.fetchAuditLogs({ type: null }).then(al => al.entries.first()),
|
||||
);
|
||||
expectType<Promise<GuildAuditLogsEntry<'ALL', 'ALL', 'ALL', 'UNKNOWN'> | undefined>>(
|
||||
expectType<Promise<GuildAuditLogsEntry<'All', 'All', 'All', 'Unknown'> | undefined>>(
|
||||
guild.fetchAuditLogs().then(al => al.entries.first()),
|
||||
);
|
||||
|
||||
expectType<Promise<null | undefined>>(
|
||||
guild.fetchAuditLogs({ type: 'MEMBER_KICK' }).then(al => al.entries.first()?.extra),
|
||||
guild.fetchAuditLogs({ type: 'MemberKick' }).then(al => al.entries.first()?.extra),
|
||||
);
|
||||
expectType<Promise<null | undefined>>(
|
||||
guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick }).then(al => al.entries.first()?.extra),
|
||||
);
|
||||
expectType<Promise<StageChannel | { id: Snowflake } | undefined>>(
|
||||
guild.fetchAuditLogs({ type: 'STAGE_INSTANCE_CREATE' }).then(al => al.entries.first()?.extra),
|
||||
guild.fetchAuditLogs({ type: 'StageInstanceCreate' }).then(al => al.entries.first()?.extra),
|
||||
);
|
||||
expectType<Promise<{ channel: GuildTextBasedChannel | { id: Snowflake }; count: number } | undefined>>(
|
||||
guild.fetchAuditLogs({ type: 'MESSAGE_DELETE' }).then(al => al.entries.first()?.extra),
|
||||
guild.fetchAuditLogs({ type: 'MessageDelete' }).then(al => al.entries.first()?.extra),
|
||||
);
|
||||
|
||||
expectType<Promise<User | null | undefined>>(
|
||||
guild.fetchAuditLogs({ type: 'MEMBER_KICK' }).then(al => al.entries.first()?.target),
|
||||
guild.fetchAuditLogs({ type: 'MemberKick' }).then(al => al.entries.first()?.target),
|
||||
);
|
||||
expectType<Promise<User | null | undefined>>(
|
||||
guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick }).then(al => al.entries.first()?.target),
|
||||
);
|
||||
expectType<Promise<StageInstance | undefined>>(
|
||||
guild.fetchAuditLogs({ type: 'STAGE_INSTANCE_CREATE' }).then(al => al.entries.first()?.target),
|
||||
guild.fetchAuditLogs({ type: 'StageInstanceCreate' }).then(al => al.entries.first()?.target),
|
||||
);
|
||||
expectType<Promise<User | undefined>>(
|
||||
guild.fetchAuditLogs({ type: 'MESSAGE_DELETE' }).then(al => al.entries.first()?.target),
|
||||
guild.fetchAuditLogs({ type: 'MessageDelete' }).then(al => al.entries.first()?.target),
|
||||
);
|
||||
|
||||
expectType<Promise<User | undefined>>(
|
||||
@@ -1255,7 +1253,7 @@ declare const NonThreadGuildBasedChannel: NonThreadGuildBasedChannel;
|
||||
declare const GuildTextBasedChannel: GuildTextBasedChannel;
|
||||
|
||||
expectType<DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel>(TextBasedChannel);
|
||||
expectType<'DM' | 'GUILD_NEWS' | 'GUILD_TEXT' | 'GUILD_PUBLIC_THREAD' | 'GUILD_PRIVATE_THREAD' | 'GUILD_NEWS_THREAD'>(
|
||||
expectType<'DM' | 'GuildNews' | 'GuildText' | 'GuildPublicThread' | 'GuildPrivateThread' | 'GuildNewsThread'>(
|
||||
TextBasedChannelTypes,
|
||||
);
|
||||
expectType<StageChannel | VoiceChannel>(VoiceBasedChannel);
|
||||
|
||||
Reference in New Issue
Block a user