mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 19:43:29 +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';
|
'use strict';
|
||||||
|
|
||||||
|
const { ChannelType } = require('discord-api-types/v9');
|
||||||
const Action = require('./Action');
|
const Action = require('./Action');
|
||||||
const { Channel } = require('../../structures/Channel');
|
const { Channel } = require('../../structures/Channel');
|
||||||
const { ChannelTypes } = require('../../util/Constants');
|
|
||||||
|
|
||||||
class ChannelUpdateAction extends Action {
|
class ChannelUpdateAction extends Action {
|
||||||
handle(data) {
|
handle(data) {
|
||||||
@@ -12,7 +12,7 @@ class ChannelUpdateAction extends Action {
|
|||||||
if (channel) {
|
if (channel) {
|
||||||
const old = channel._update(data);
|
const old = channel._update(data);
|
||||||
|
|
||||||
if (ChannelTypes[channel.type] !== data.type) {
|
if (ChannelType[channel.type] !== data.type) {
|
||||||
const newChannel = Channel.create(this.client, data, channel.guild);
|
const newChannel = Channel.create(this.client, data, channel.guild);
|
||||||
for (const [id, message] of channel.messages.cache) newChannel.messages.cache.set(id, message);
|
for (const [id, message] of channel.messages.cache) newChannel.messages.cache.set(id, message);
|
||||||
channel = newChannel;
|
channel = newChannel;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { InteractionType, ComponentType, ApplicationCommandType } = require('discord-api-types/v9');
|
||||||
const Action = require('./Action');
|
const Action = require('./Action');
|
||||||
const AutocompleteInteraction = require('../../structures/AutocompleteInteraction');
|
const AutocompleteInteraction = require('../../structures/AutocompleteInteraction');
|
||||||
const ButtonInteraction = require('../../structures/ButtonInteraction');
|
const ButtonInteraction = require('../../structures/ButtonInteraction');
|
||||||
@@ -7,7 +8,7 @@ const ChatInputCommandInteraction = require('../../structures/ChatInputCommandIn
|
|||||||
const MessageContextMenuCommandInteraction = require('../../structures/MessageContextMenuCommandInteraction');
|
const MessageContextMenuCommandInteraction = require('../../structures/MessageContextMenuCommandInteraction');
|
||||||
const SelectMenuInteraction = require('../../structures/SelectMenuInteraction');
|
const SelectMenuInteraction = require('../../structures/SelectMenuInteraction');
|
||||||
const UserContextMenuCommandInteraction = require('../../structures/UserContextMenuCommandInteraction');
|
const UserContextMenuCommandInteraction = require('../../structures/UserContextMenuCommandInteraction');
|
||||||
const { Events, InteractionTypes, MessageComponentTypes, ApplicationCommandTypes } = require('../../util/Constants');
|
const { Events } = require('../../util/Constants');
|
||||||
|
|
||||||
class InteractionCreateAction extends Action {
|
class InteractionCreateAction extends Action {
|
||||||
handle(data) {
|
handle(data) {
|
||||||
@@ -16,18 +17,18 @@ class InteractionCreateAction extends Action {
|
|||||||
// Resolve and cache partial channels for Interaction#channel getter
|
// Resolve and cache partial channels for Interaction#channel getter
|
||||||
this.getChannel(data);
|
this.getChannel(data);
|
||||||
|
|
||||||
let InteractionType;
|
let InteractionClass;
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case InteractionTypes.APPLICATION_COMMAND:
|
case InteractionType.ApplicationCommand:
|
||||||
switch (data.data.type) {
|
switch (data.data.type) {
|
||||||
case ApplicationCommandTypes.CHAT_INPUT:
|
case ApplicationCommandType.ChatInput:
|
||||||
InteractionType = ChatInputCommandInteraction;
|
InteractionClass = ChatInputCommandInteraction;
|
||||||
break;
|
break;
|
||||||
case ApplicationCommandTypes.USER:
|
case ApplicationCommandType.User:
|
||||||
InteractionType = UserContextMenuCommandInteraction;
|
InteractionClass = UserContextMenuCommandInteraction;
|
||||||
break;
|
break;
|
||||||
case ApplicationCommandTypes.MESSAGE:
|
case ApplicationCommandType.Message:
|
||||||
InteractionType = MessageContextMenuCommandInteraction;
|
InteractionClass = MessageContextMenuCommandInteraction;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
client.emit(
|
client.emit(
|
||||||
@@ -37,13 +38,13 @@ class InteractionCreateAction extends Action {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case InteractionTypes.MESSAGE_COMPONENT:
|
case InteractionType.MessageComponent:
|
||||||
switch (data.data.component_type) {
|
switch (data.data.component_type) {
|
||||||
case MessageComponentTypes.BUTTON:
|
case ComponentType.Button:
|
||||||
InteractionType = ButtonInteraction;
|
InteractionClass = ButtonInteraction;
|
||||||
break;
|
break;
|
||||||
case MessageComponentTypes.SELECT_MENU:
|
case ComponentType.SelectMenu:
|
||||||
InteractionType = SelectMenuInteraction;
|
InteractionClass = SelectMenuInteraction;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
client.emit(
|
client.emit(
|
||||||
@@ -53,15 +54,15 @@ class InteractionCreateAction extends Action {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case InteractionTypes.APPLICATION_COMMAND_AUTOCOMPLETE:
|
case InteractionType.ApplicationCommandAutocomplete:
|
||||||
InteractionType = AutocompleteInteraction;
|
InteractionClass = AutocompleteInteraction;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
client.emit(Events.DEBUG, `[INTERACTION] Received interaction with unknown type: ${data.type}`);
|
client.emit(Events.DEBUG, `[INTERACTION] Received interaction with unknown type: ${data.type}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const interaction = new InteractionType(client, data);
|
const interaction = new InteractionClass(client, data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emitted when an interaction is created.
|
* Emitted when an interaction is created.
|
||||||
|
|||||||
@@ -155,3 +155,28 @@ exports.WelcomeChannel = require('./structures/WelcomeChannel');
|
|||||||
exports.WelcomeScreen = require('./structures/WelcomeScreen');
|
exports.WelcomeScreen = require('./structures/WelcomeScreen');
|
||||||
|
|
||||||
exports.WebSocket = require('./WebSocket');
|
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';
|
'use strict';
|
||||||
|
|
||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
|
const { ApplicationCommandType } = require('discord-api-types/v9');
|
||||||
const ApplicationCommandPermissionsManager = require('./ApplicationCommandPermissionsManager');
|
const ApplicationCommandPermissionsManager = require('./ApplicationCommandPermissionsManager');
|
||||||
const CachedManager = require('./CachedManager');
|
const CachedManager = require('./CachedManager');
|
||||||
const { TypeError } = require('../errors');
|
const { TypeError } = require('../errors');
|
||||||
const ApplicationCommand = require('../structures/ApplicationCommand');
|
const ApplicationCommand = require('../structures/ApplicationCommand');
|
||||||
const { ApplicationCommandTypes } = require('../util/Constants');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages API methods for application commands and stores their cache.
|
* Manages API methods for application commands and stores their cache.
|
||||||
@@ -207,7 +207,7 @@ class ApplicationCommandManager extends CachedManager {
|
|||||||
return {
|
return {
|
||||||
name: command.name,
|
name: command.name,
|
||||||
description: command.description,
|
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)),
|
options: command.options?.map(o => ApplicationCommand.transformOption(o)),
|
||||||
default_permission: command.defaultPermission ?? command.default_permission,
|
default_permission: command.defaultPermission ?? command.default_permission,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
|
const { ApplicationCommandPermissionType, RESTJSONErrorCodes } = require('discord-api-types/v9');
|
||||||
const BaseManager = require('./BaseManager');
|
const BaseManager = require('./BaseManager');
|
||||||
const { Error, TypeError } = require('../errors');
|
const { Error, TypeError } = require('../errors');
|
||||||
const { ApplicationCommandPermissionTypes, APIErrors } = require('../util/Constants');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages API methods for permissions of Application Commands.
|
* Manages API methods for permissions of Application Commands.
|
||||||
@@ -230,7 +230,7 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
|||||||
try {
|
try {
|
||||||
existing = await this.fetch({ guild: guildId, command: commandId });
|
existing = await this.fetch({ guild: guildId, command: commandId });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code !== APIErrors.UNKNOWN_APPLICATION_COMMAND_PERMISSIONS) throw error;
|
if (error.code !== RESTJSONErrorCodes.UnknownApplicationCommandPermissions) throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newPermissions = permissions.slice();
|
const newPermissions = permissions.slice();
|
||||||
@@ -319,7 +319,7 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
|||||||
try {
|
try {
|
||||||
existing = await this.fetch({ guild: guildId, command: commandId });
|
existing = await this.fetch({ guild: guildId, command: commandId });
|
||||||
} catch (error) {
|
} 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));
|
const permissions = existing.filter(perm => !resolvedIds.includes(perm.id));
|
||||||
@@ -366,7 +366,7 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
|||||||
try {
|
try {
|
||||||
existing = await this.fetch({ guild: guildId, command: commandId });
|
existing = await this.fetch({ guild: guildId, command: commandId });
|
||||||
} catch (error) {
|
} 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);
|
return existing.some(perm => perm.id === resolvedId);
|
||||||
@@ -403,7 +403,7 @@ class ApplicationCommandPermissionsManager extends BaseManager {
|
|||||||
type:
|
type:
|
||||||
typeof permissions.type === 'number' && !received
|
typeof permissions.type === 'number' && !received
|
||||||
? permissions.type
|
? permissions.type
|
||||||
: ApplicationCommandPermissionTypes[permissions.type],
|
: ApplicationCommandPermissionType[permissions.type],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,14 @@
|
|||||||
|
|
||||||
const process = require('node:process');
|
const process = require('node:process');
|
||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
|
const { ChannelType } = require('discord-api-types/v9');
|
||||||
const CachedManager = require('./CachedManager');
|
const CachedManager = require('./CachedManager');
|
||||||
const ThreadManager = require('./ThreadManager');
|
const ThreadManager = require('./ThreadManager');
|
||||||
const { Error } = require('../errors');
|
const { Error } = require('../errors');
|
||||||
const GuildChannel = require('../structures/GuildChannel');
|
const GuildChannel = require('../structures/GuildChannel');
|
||||||
const PermissionOverwrites = require('../structures/PermissionOverwrites');
|
const PermissionOverwrites = require('../structures/PermissionOverwrites');
|
||||||
const ThreadChannel = require('../structures/ThreadChannel');
|
const ThreadChannel = require('../structures/ThreadChannel');
|
||||||
const { ChannelTypes, ThreadChannelTypes } = require('../util/Constants');
|
const { ThreadChannelTypes } = require('../util/Constants');
|
||||||
|
|
||||||
let cacheWarningEmitted = false;
|
let cacheWarningEmitted = false;
|
||||||
let storeChannelDeprecationEmitted = false;
|
let storeChannelDeprecationEmitted = false;
|
||||||
@@ -139,9 +140,9 @@ class GuildChannelManager extends CachedManager {
|
|||||||
) {
|
) {
|
||||||
parent &&= this.client.channels.resolveId(parent);
|
parent &&= this.client.channels.resolveId(parent);
|
||||||
permissionOverwrites &&= permissionOverwrites.map(o => PermissionOverwrites.resolve(o, this.guild));
|
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;
|
storeChannelDeprecationEmitted = true;
|
||||||
process.emitWarning(
|
process.emitWarning(
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
|
|||||||
@@ -3,6 +3,13 @@
|
|||||||
const process = require('node:process');
|
const process = require('node:process');
|
||||||
const { setTimeout } = require('node:timers');
|
const { setTimeout } = require('node:timers');
|
||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
|
const {
|
||||||
|
GuildVerificationLevel,
|
||||||
|
GuildDefaultMessageNotifications,
|
||||||
|
GuildExplicitContentFilter,
|
||||||
|
ChannelType,
|
||||||
|
OverwriteType,
|
||||||
|
} = require('discord-api-types/v9');
|
||||||
const CachedManager = require('./CachedManager');
|
const CachedManager = require('./CachedManager');
|
||||||
const { Guild } = require('../structures/Guild');
|
const { Guild } = require('../structures/Guild');
|
||||||
const GuildChannel = require('../structures/GuildChannel');
|
const GuildChannel = require('../structures/GuildChannel');
|
||||||
@@ -11,14 +18,7 @@ const { GuildMember } = require('../structures/GuildMember');
|
|||||||
const Invite = require('../structures/Invite');
|
const Invite = require('../structures/Invite');
|
||||||
const OAuth2Guild = require('../structures/OAuth2Guild');
|
const OAuth2Guild = require('../structures/OAuth2Guild');
|
||||||
const { Role } = require('../structures/Role');
|
const { Role } = require('../structures/Role');
|
||||||
const {
|
const { Events } = require('../util/Constants');
|
||||||
ChannelTypes,
|
|
||||||
Events,
|
|
||||||
OverwriteTypes,
|
|
||||||
VerificationLevels,
|
|
||||||
DefaultMessageNotificationLevels,
|
|
||||||
ExplicitContentFilterLevels,
|
|
||||||
} = require('../util/Constants');
|
|
||||||
const DataResolver = require('../util/DataResolver');
|
const DataResolver = require('../util/DataResolver');
|
||||||
const Permissions = require('../util/Permissions');
|
const Permissions = require('../util/Permissions');
|
||||||
const SystemChannelFlags = require('../util/SystemChannelFlags');
|
const SystemChannelFlags = require('../util/SystemChannelFlags');
|
||||||
@@ -182,16 +182,16 @@ class GuildManager extends CachedManager {
|
|||||||
) {
|
) {
|
||||||
icon = await DataResolver.resolveImage(icon);
|
icon = await DataResolver.resolveImage(icon);
|
||||||
if (typeof verificationLevel === 'string') {
|
if (typeof verificationLevel === 'string') {
|
||||||
verificationLevel = VerificationLevels[verificationLevel];
|
verificationLevel = GuildVerificationLevel[verificationLevel];
|
||||||
}
|
}
|
||||||
if (typeof defaultMessageNotifications === 'string') {
|
if (typeof defaultMessageNotifications === 'string') {
|
||||||
defaultMessageNotifications = DefaultMessageNotificationLevels[defaultMessageNotifications];
|
defaultMessageNotifications = GuildDefaultMessageNotifications[defaultMessageNotifications];
|
||||||
}
|
}
|
||||||
if (typeof explicitContentFilter === 'string') {
|
if (typeof explicitContentFilter === 'string') {
|
||||||
explicitContentFilter = ExplicitContentFilterLevels[explicitContentFilter];
|
explicitContentFilter = GuildExplicitContentFilter[explicitContentFilter];
|
||||||
}
|
}
|
||||||
for (const channel of channels) {
|
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;
|
channel.parent_id = channel.parentId;
|
||||||
delete channel.parentId;
|
delete channel.parentId;
|
||||||
channel.user_limit = channel.userLimit;
|
channel.user_limit = channel.userLimit;
|
||||||
@@ -204,7 +204,7 @@ class GuildManager extends CachedManager {
|
|||||||
if (!channel.permissionOverwrites) continue;
|
if (!channel.permissionOverwrites) continue;
|
||||||
for (const overwrite of channel.permissionOverwrites) {
|
for (const overwrite of channel.permissionOverwrites) {
|
||||||
if (typeof overwrite.type === 'string') {
|
if (typeof overwrite.type === 'string') {
|
||||||
overwrite.type = OverwriteTypes[overwrite.type];
|
overwrite.type = OverwriteType[overwrite.type];
|
||||||
}
|
}
|
||||||
overwrite.allow &&= Permissions.resolve(overwrite.allow).toString();
|
overwrite.allow &&= Permissions.resolve(overwrite.allow).toString();
|
||||||
overwrite.deny &&= Permissions.resolve(overwrite.deny).toString();
|
overwrite.deny &&= Permissions.resolve(overwrite.deny).toString();
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
|
const {
|
||||||
|
GuildScheduledEventPrivacyLevel,
|
||||||
|
GuildScheduledEventEntityType,
|
||||||
|
GuildScheduledEventStatus,
|
||||||
|
} = require('discord-api-types/v9');
|
||||||
const CachedManager = require('./CachedManager');
|
const CachedManager = require('./CachedManager');
|
||||||
const { TypeError, Error } = require('../errors');
|
const { TypeError, Error } = require('../errors');
|
||||||
const { GuildScheduledEvent } = require('../structures/GuildScheduledEvent');
|
const { GuildScheduledEvent } = require('../structures/GuildScheduledEvent');
|
||||||
const { PrivacyLevels, GuildScheduledEventEntityTypes, GuildScheduledEventStatuses } = require('../util/Constants');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages API methods for GuildScheduledEvents and stores their cache.
|
* Manages API methods for GuildScheduledEvents and stores their cache.
|
||||||
@@ -78,11 +82,11 @@ class GuildScheduledEventManager extends CachedManager {
|
|||||||
reason,
|
reason,
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
if (typeof privacyLevel === 'string') privacyLevel = PrivacyLevels[privacyLevel];
|
if (typeof privacyLevel === 'string') privacyLevel = GuildScheduledEventPrivacyLevel[privacyLevel];
|
||||||
if (typeof entityType === 'string') entityType = GuildScheduledEventEntityTypes[entityType];
|
if (typeof entityType === 'string') entityType = GuildScheduledEventEntityType[entityType];
|
||||||
|
|
||||||
let entity_metadata, channel_id;
|
let entity_metadata, channel_id;
|
||||||
if (entityType === GuildScheduledEventEntityTypes.EXTERNAL) {
|
if (entityType === GuildScheduledEventEntityType.External) {
|
||||||
channel_id = typeof channel === 'undefined' ? channel : null;
|
channel_id = typeof channel === 'undefined' ? channel : null;
|
||||||
entity_metadata = { location: entityMetadata?.location };
|
entity_metadata = { location: entityMetadata?.location };
|
||||||
} else {
|
} else {
|
||||||
@@ -199,9 +203,9 @@ class GuildScheduledEventManager extends CachedManager {
|
|||||||
reason,
|
reason,
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
if (typeof privacyLevel === 'string') privacyLevel = PrivacyLevels[privacyLevel];
|
if (typeof privacyLevel === 'string') privacyLevel = GuildScheduledEventPrivacyLevel[privacyLevel];
|
||||||
if (typeof entityType === 'string') entityType = GuildScheduledEventEntityTypes[entityType];
|
if (typeof entityType === 'string') entityType = GuildScheduledEventEntityType[entityType];
|
||||||
if (typeof status === 'string') status = GuildScheduledEventStatuses[status];
|
if (typeof status === 'string') status = GuildScheduledEventStatus[status];
|
||||||
|
|
||||||
let entity_metadata;
|
let entity_metadata;
|
||||||
if (entityMetadata) {
|
if (entityMetadata) {
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
const process = require('node:process');
|
const process = require('node:process');
|
||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
|
const { OverwriteType } = require('discord-api-types/v9');
|
||||||
const CachedManager = require('./CachedManager');
|
const CachedManager = require('./CachedManager');
|
||||||
const { TypeError } = require('../errors');
|
const { TypeError } = require('../errors');
|
||||||
const PermissionOverwrites = require('../structures/PermissionOverwrites');
|
const PermissionOverwrites = require('../structures/PermissionOverwrites');
|
||||||
const { Role } = require('../structures/Role');
|
const { Role } = require('../structures/Role');
|
||||||
const { OverwriteTypes } = require('../util/Constants');
|
|
||||||
|
|
||||||
let cacheWarningEmitted = false;
|
let cacheWarningEmitted = false;
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ class PermissionOverwriteManager extends CachedManager {
|
|||||||
if (typeof type !== 'number') {
|
if (typeof type !== 'number') {
|
||||||
userOrRole = this.channel.guild.roles.resolve(userOrRole) ?? this.client.users.resolve(userOrRole);
|
userOrRole = this.channel.guild.roles.resolve(userOrRole) ?? this.client.users.resolve(userOrRole);
|
||||||
if (!userOrRole) throw new TypeError('INVALID_TYPE', 'parameter', 'User nor a Role');
|
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);
|
const { allow, deny } = PermissionOverwrites.resolveOverwriteOptions(options, existing);
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { GuildScheduledEventPrivacyLevel } = require('discord-api-types/v9');
|
||||||
const CachedManager = require('./CachedManager');
|
const CachedManager = require('./CachedManager');
|
||||||
const { TypeError, Error } = require('../errors');
|
const { TypeError, Error } = require('../errors');
|
||||||
const { StageInstance } = require('../structures/StageInstance');
|
const { StageInstance } = require('../structures/StageInstance');
|
||||||
const { PrivacyLevels } = require('../util/Constants');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages API methods for {@link StageInstance} objects and holds their cache.
|
* 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);
|
if (typeof options !== 'object') throw new TypeError('INVALID_TYPE', 'options', 'object', true);
|
||||||
let { topic, privacyLevel } = options;
|
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({
|
const data = await this.client.api['stage-instances'].post({
|
||||||
data: {
|
data: {
|
||||||
@@ -122,7 +122,7 @@ class StageInstanceManager extends CachedManager {
|
|||||||
|
|
||||||
let { topic, privacyLevel } = options;
|
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({
|
const data = await this.client.api('stage-instances', channelId).patch({
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
|
const { ChannelType } = require('discord-api-types/v9');
|
||||||
const CachedManager = require('./CachedManager');
|
const CachedManager = require('./CachedManager');
|
||||||
const { TypeError } = require('../errors');
|
const { TypeError } = require('../errors');
|
||||||
const ThreadChannel = require('../structures/ThreadChannel');
|
const ThreadChannel = require('../structures/ThreadChannel');
|
||||||
const { ChannelTypes } = require('../util/Constants');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages API methods for {@link ThreadChannel} objects and stores their cache.
|
* 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') {
|
if (type && typeof type !== 'string' && typeof type !== 'number') {
|
||||||
throw new TypeError('INVALID_TYPE', 'type', 'ThreadChannelType or Number');
|
throw new TypeError('INVALID_TYPE', 'type', 'ThreadChannelType or Number');
|
||||||
}
|
}
|
||||||
let resolvedType =
|
let resolvedType = this.channel.type === 'GUILD_NEWS' ? ChannelType.GuildNewsThread : ChannelType.GuildPublicThread;
|
||||||
this.channel.type === 'GUILD_NEWS' ? ChannelTypes.GUILD_NEWS_THREAD : ChannelTypes.GUILD_PUBLIC_THREAD;
|
|
||||||
if (startMessage) {
|
if (startMessage) {
|
||||||
const startMessageId = this.channel.messages.resolveId(startMessage);
|
const startMessageId = this.channel.messages.resolveId(startMessage);
|
||||||
if (!startMessageId) throw new TypeError('INVALID_TYPE', 'startMessage', 'MessageResolvable');
|
if (!startMessageId) throw new TypeError('INVALID_TYPE', 'startMessage', 'MessageResolvable');
|
||||||
path = path.messages(startMessageId);
|
path = path.messages(startMessageId);
|
||||||
} else if (this.channel.type !== 'GUILD_NEWS') {
|
} 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') {
|
if (autoArchiveDuration === 'MAX') {
|
||||||
autoArchiveDuration = 1440;
|
autoArchiveDuration = 1440;
|
||||||
@@ -134,7 +133,7 @@ class ThreadManager extends CachedManager {
|
|||||||
name,
|
name,
|
||||||
auto_archive_duration: autoArchiveDuration,
|
auto_archive_duration: autoArchiveDuration,
|
||||||
type: resolvedType,
|
type: resolvedType,
|
||||||
invitable: resolvedType === ChannelTypes.GUILD_PRIVATE_THREAD ? invitable : undefined,
|
invitable: resolvedType === ChannelType.GuildPrivateThread ? invitable : undefined,
|
||||||
rate_limit_per_user: rateLimitPerUser,
|
rate_limit_per_user: rateLimitPerUser,
|
||||||
},
|
},
|
||||||
reason,
|
reason,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { GuildVerificationLevel, GuildNSFWLevel } = require('discord-api-types/v9');
|
||||||
const BaseGuild = require('./BaseGuild');
|
const BaseGuild = require('./BaseGuild');
|
||||||
const { VerificationLevels, NSFWLevels } = require('../util/Constants');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bundles common attributes and methods between {@link Guild} and {@link InviteGuild}
|
* 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
|
* The verification level of the guild
|
||||||
* @type {VerificationLevel}
|
* @type {VerificationLevel}
|
||||||
*/
|
*/
|
||||||
this.verificationLevel = VerificationLevels[data.verification_level];
|
this.verificationLevel = GuildVerificationLevel[data.verification_level];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('vanity_url_code' in data) {
|
if ('vanity_url_code' in data) {
|
||||||
@@ -62,7 +62,7 @@ class AnonymousGuild extends BaseGuild {
|
|||||||
* The NSFW level of this guild
|
* The NSFW level of this guild
|
||||||
* @type {NSFWLevel}
|
* @type {NSFWLevel}
|
||||||
*/
|
*/
|
||||||
this.nsfwLevel = NSFWLevels[data.nsfw_level];
|
this.nsfwLevel = GuildNSFWLevel[data.nsfw_level];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||||
|
const { ApplicationCommandType, ApplicationCommandOptionType, ChannelType } = require('discord-api-types/v9');
|
||||||
const Base = require('./Base');
|
const Base = require('./Base');
|
||||||
const ApplicationCommandPermissionsManager = require('../managers/ApplicationCommandPermissionsManager');
|
const ApplicationCommandPermissionsManager = require('../managers/ApplicationCommandPermissionsManager');
|
||||||
const { ApplicationCommandOptionTypes, ApplicationCommandTypes, ChannelTypes } = require('../util/Constants');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an application command.
|
* Represents an application command.
|
||||||
@@ -48,7 +48,7 @@ class ApplicationCommand extends Base {
|
|||||||
* The type of this application command
|
* The type of this application command
|
||||||
* @type {ApplicationCommandType}
|
* @type {ApplicationCommandType}
|
||||||
*/
|
*/
|
||||||
this.type = ApplicationCommandTypes[data.type];
|
this.type = ApplicationCommandType[data.type];
|
||||||
|
|
||||||
this._patch(data);
|
this._patch(data);
|
||||||
}
|
}
|
||||||
@@ -233,7 +233,7 @@ class ApplicationCommand extends Base {
|
|||||||
if (command.id && this.id !== command.id) return false;
|
if (command.id && this.id !== command.id) return false;
|
||||||
|
|
||||||
// Check top level parameters
|
// 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 (
|
if (
|
||||||
command.name !== this.name ||
|
command.name !== this.name ||
|
||||||
('description' in command && command.description !== this.description) ||
|
('description' in command && command.description !== this.description) ||
|
||||||
@@ -289,7 +289,7 @@ class ApplicationCommand extends Base {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
static _optionEquals(existing, option, enforceOptionOrder = false) {
|
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 (
|
if (
|
||||||
option.name !== existing.name ||
|
option.name !== existing.name ||
|
||||||
optionType !== existing.type ||
|
optionType !== existing.type ||
|
||||||
@@ -326,7 +326,7 @@ class ApplicationCommand extends Base {
|
|||||||
|
|
||||||
if (existing.channelTypes) {
|
if (existing.channelTypes) {
|
||||||
const newTypes = (option.channelTypes ?? option.channel_types).map(type =>
|
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) {
|
for (const type of existing.channelTypes) {
|
||||||
if (!newTypes.includes(type)) return false;
|
if (!newTypes.includes(type)) return false;
|
||||||
@@ -370,12 +370,12 @@ class ApplicationCommand extends Base {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
static transformOption(option, received) {
|
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 channelTypesKey = received ? 'channelTypes' : 'channel_types';
|
||||||
const minValueKey = received ? 'minValue' : 'min_value';
|
const minValueKey = received ? 'minValue' : 'min_value';
|
||||||
const maxValueKey = received ? 'maxValue' : 'max_value';
|
const maxValueKey = received ? 'maxValue' : 'max_value';
|
||||||
return {
|
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,
|
name: option.name,
|
||||||
description: option.description,
|
description: option.description,
|
||||||
required:
|
required:
|
||||||
@@ -384,8 +384,8 @@ class ApplicationCommand extends Base {
|
|||||||
choices: option.choices,
|
choices: option.choices,
|
||||||
options: option.options?.map(o => this.transformOption(o, received)),
|
options: option.options?.map(o => this.transformOption(o, received)),
|
||||||
[channelTypesKey]: received
|
[channelTypesKey]: received
|
||||||
? option.channel_types?.map(type => ChannelTypes[type])
|
? option.channel_types?.map(type => ChannelType[type])
|
||||||
: option.channelTypes?.map(type => (typeof type === 'string' ? ChannelTypes[type] : type)) ??
|
: option.channelTypes?.map(type => (typeof type === 'string' ? ChannelType[type] : type)) ??
|
||||||
// When transforming to API data, accept API data
|
// When transforming to API data, accept API data
|
||||||
option.channel_types,
|
option.channel_types,
|
||||||
[minValueKey]: option.minValue ?? option.min_value,
|
[minValueKey]: option.minValue ?? option.min_value,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { ApplicationCommandOptionType, InteractionResponseType } = require('discord-api-types/v9');
|
||||||
const CommandInteractionOptionResolver = require('./CommandInteractionOptionResolver');
|
const CommandInteractionOptionResolver = require('./CommandInteractionOptionResolver');
|
||||||
const Interaction = require('./Interaction');
|
const Interaction = require('./Interaction');
|
||||||
const { InteractionResponseTypes, ApplicationCommandOptionTypes } = require('../util/Constants');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an autocomplete interaction.
|
* Represents an autocomplete interaction.
|
||||||
@@ -64,7 +64,7 @@ class AutocompleteInteraction extends Interaction {
|
|||||||
transformOption(option) {
|
transformOption(option) {
|
||||||
const result = {
|
const result = {
|
||||||
name: option.name,
|
name: option.name,
|
||||||
type: ApplicationCommandOptionTypes[option.type],
|
type: ApplicationCommandOptionType[option.type],
|
||||||
};
|
};
|
||||||
|
|
||||||
if ('value' in option) result.value = option.value;
|
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({
|
await this.client.api.interactions(this.id, this.token).callback.post({
|
||||||
data: {
|
data: {
|
||||||
type: InteractionResponseTypes.APPLICATION_COMMAND_AUTOCOMPLETE_RESULT,
|
type: InteractionResponseType.ApplicationCommandAutocompleteResult,
|
||||||
data: {
|
data: {
|
||||||
choices: options,
|
choices: options,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||||
|
const { ChannelType } = require('discord-api-types/v9');
|
||||||
const Base = require('./Base');
|
const Base = require('./Base');
|
||||||
let CategoryChannel;
|
let CategoryChannel;
|
||||||
let DMChannel;
|
let DMChannel;
|
||||||
@@ -10,7 +11,7 @@ let StoreChannel;
|
|||||||
let TextChannel;
|
let TextChannel;
|
||||||
let ThreadChannel;
|
let ThreadChannel;
|
||||||
let VoiceChannel;
|
let VoiceChannel;
|
||||||
const { ChannelTypes, ThreadChannelTypes, VoiceBasedChannelTypes } = require('../util/Constants');
|
const { ThreadChannelTypes, VoiceBasedChannelTypes } = require('../util/Constants');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents any channel on Discord.
|
* Represents any channel on Discord.
|
||||||
@@ -21,7 +22,7 @@ class Channel extends Base {
|
|||||||
constructor(client, data, immediatePatch = true) {
|
constructor(client, data, immediatePatch = true) {
|
||||||
super(client);
|
super(client);
|
||||||
|
|
||||||
const type = ChannelTypes[data?.type];
|
const type = ChannelType[data?.type];
|
||||||
/**
|
/**
|
||||||
* The type of the channel
|
* The type of the channel
|
||||||
* @type {ChannelType}
|
* @type {ChannelType}
|
||||||
@@ -137,9 +138,9 @@ class Channel extends Base {
|
|||||||
|
|
||||||
let channel;
|
let channel;
|
||||||
if (!data.guild_id && !guild) {
|
if (!data.guild_id && !guild) {
|
||||||
if ((data.recipients && data.type !== ChannelTypes.GROUP_DM) || data.type === ChannelTypes.DM) {
|
if ((data.recipients && data.type !== ChannelType.GroupDM) || data.type === ChannelType.DM) {
|
||||||
channel = new DMChannel(client, data);
|
channel = new DMChannel(client, data);
|
||||||
} else if (data.type === ChannelTypes.GROUP_DM) {
|
} else if (data.type === ChannelType.GroupDM) {
|
||||||
const PartialGroupDMChannel = require('./PartialGroupDMChannel');
|
const PartialGroupDMChannel = require('./PartialGroupDMChannel');
|
||||||
channel = new PartialGroupDMChannel(client, data);
|
channel = new PartialGroupDMChannel(client, data);
|
||||||
}
|
}
|
||||||
@@ -148,33 +149,33 @@ class Channel extends Base {
|
|||||||
|
|
||||||
if (guild || allowUnknownGuild) {
|
if (guild || allowUnknownGuild) {
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case ChannelTypes.GUILD_TEXT: {
|
case ChannelType.GuildText: {
|
||||||
channel = new TextChannel(guild, data, client);
|
channel = new TextChannel(guild, data, client);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ChannelTypes.GUILD_VOICE: {
|
case ChannelType.GuildVoice: {
|
||||||
channel = new VoiceChannel(guild, data, client);
|
channel = new VoiceChannel(guild, data, client);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ChannelTypes.GUILD_CATEGORY: {
|
case ChannelType.GuildCategory: {
|
||||||
channel = new CategoryChannel(guild, data, client);
|
channel = new CategoryChannel(guild, data, client);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ChannelTypes.GUILD_NEWS: {
|
case ChannelType.GuildNews: {
|
||||||
channel = new NewsChannel(guild, data, client);
|
channel = new NewsChannel(guild, data, client);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ChannelTypes.GUILD_STORE: {
|
case ChannelType.GuildStore: {
|
||||||
channel = new StoreChannel(guild, data, client);
|
channel = new StoreChannel(guild, data, client);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ChannelTypes.GUILD_STAGE_VOICE: {
|
case ChannelType.GuildStageVoice: {
|
||||||
channel = new StageChannel(guild, data, client);
|
channel = new StageChannel(guild, data, client);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ChannelTypes.GUILD_NEWS_THREAD:
|
case ChannelType.GuildNewsThread:
|
||||||
case ChannelTypes.GUILD_PUBLIC_THREAD:
|
case ChannelType.GuildPublicThread:
|
||||||
case ChannelTypes.GUILD_PRIVATE_THREAD: {
|
case ChannelType.GuildPrivateThread: {
|
||||||
channel = new ThreadChannel(guild, data, client, fromInteraction);
|
channel = new ThreadChannel(guild, data, client, fromInteraction);
|
||||||
if (!allowUnknownGuild) channel.parent?.threads.cache.set(channel.id, channel);
|
if (!allowUnknownGuild) channel.parent?.threads.cache.set(channel.id, channel);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { ActivityType } = require('discord-api-types/v9');
|
||||||
const { Presence } = require('./Presence');
|
const { Presence } = require('./Presence');
|
||||||
const { TypeError } = require('../errors');
|
const { TypeError } = require('../errors');
|
||||||
const { ActivityTypes, Opcodes } = require('../util/Constants');
|
const { Opcodes } = require('../util/Constants');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the client's presence.
|
* Represents the client's presence.
|
||||||
@@ -52,7 +53,7 @@ class ClientPresence extends Presence {
|
|||||||
activity.type ??= 0;
|
activity.type ??= 0;
|
||||||
|
|
||||||
data.activities.push({
|
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,
|
name: activity.name,
|
||||||
url: activity.url,
|
url: activity.url,
|
||||||
});
|
});
|
||||||
@@ -61,7 +62,7 @@ class ClientPresence extends Presence {
|
|||||||
data.activities.push(
|
data.activities.push(
|
||||||
...this.activities.map(a => ({
|
...this.activities.map(a => ({
|
||||||
name: a.name,
|
name: a.name,
|
||||||
type: ActivityTypes[a.type],
|
type: ActivityType[a.type],
|
||||||
url: a.url ?? undefined,
|
url: a.url ?? undefined,
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
|
const { ApplicationCommandType } = require('discord-api-types/v9');
|
||||||
const Interaction = require('./Interaction');
|
const Interaction = require('./Interaction');
|
||||||
const InteractionWebhook = require('./InteractionWebhook');
|
const InteractionWebhook = require('./InteractionWebhook');
|
||||||
const InteractionResponses = require('./interfaces/InteractionResponses');
|
const InteractionResponses = require('./interfaces/InteractionResponses');
|
||||||
const { ApplicationCommandOptionTypes } = require('../util/Constants');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a command interaction.
|
* Represents a command interaction.
|
||||||
@@ -151,7 +151,7 @@ class CommandInteraction extends Interaction {
|
|||||||
transformOption(option, resolved) {
|
transformOption(option, resolved) {
|
||||||
const result = {
|
const result = {
|
||||||
name: option.name,
|
name: option.name,
|
||||||
type: ApplicationCommandOptionTypes[option.type],
|
type: ApplicationCommandType[option.type],
|
||||||
};
|
};
|
||||||
|
|
||||||
if ('value' in option) result.value = option.value;
|
if ('value' in option) result.value = option.value;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { ApplicationCommandType } = require('discord-api-types/v9');
|
||||||
const CommandInteraction = require('./CommandInteraction');
|
const CommandInteraction = require('./CommandInteraction');
|
||||||
const CommandInteractionOptionResolver = require('./CommandInteractionOptionResolver');
|
const CommandInteractionOptionResolver = require('./CommandInteractionOptionResolver');
|
||||||
const { ApplicationCommandOptionTypes, ApplicationCommandTypes } = require('../util/Constants');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a context menu interaction.
|
* 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
|
* The type of the target of the interaction; either USER or MESSAGE
|
||||||
* @type {ApplicationCommandType}
|
* @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]) {
|
if (resolved.users?.[target_id]) {
|
||||||
result.push(
|
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';
|
'use strict';
|
||||||
|
|
||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
|
const {
|
||||||
|
GuildPremiumTier,
|
||||||
|
GuildMFALevel,
|
||||||
|
GuildExplicitContentFilter,
|
||||||
|
GuildDefaultMessageNotifications,
|
||||||
|
GuildVerificationLevel,
|
||||||
|
ChannelType,
|
||||||
|
} = require('discord-api-types/v9');
|
||||||
const AnonymousGuild = require('./AnonymousGuild');
|
const AnonymousGuild = require('./AnonymousGuild');
|
||||||
const GuildAuditLogs = require('./GuildAuditLogs');
|
const GuildAuditLogs = require('./GuildAuditLogs');
|
||||||
const GuildPreview = require('./GuildPreview');
|
const GuildPreview = require('./GuildPreview');
|
||||||
@@ -21,16 +29,7 @@ const PresenceManager = require('../managers/PresenceManager');
|
|||||||
const RoleManager = require('../managers/RoleManager');
|
const RoleManager = require('../managers/RoleManager');
|
||||||
const StageInstanceManager = require('../managers/StageInstanceManager');
|
const StageInstanceManager = require('../managers/StageInstanceManager');
|
||||||
const VoiceStateManager = require('../managers/VoiceStateManager');
|
const VoiceStateManager = require('../managers/VoiceStateManager');
|
||||||
const {
|
const { PartialTypes, Status } = require('../util/Constants');
|
||||||
ChannelTypes,
|
|
||||||
DefaultMessageNotificationLevels,
|
|
||||||
PartialTypes,
|
|
||||||
VerificationLevels,
|
|
||||||
ExplicitContentFilterLevels,
|
|
||||||
Status,
|
|
||||||
MFALevels,
|
|
||||||
PremiumTiers,
|
|
||||||
} = require('../util/Constants');
|
|
||||||
const DataResolver = require('../util/DataResolver');
|
const DataResolver = require('../util/DataResolver');
|
||||||
const SystemChannelFlags = require('../util/SystemChannelFlags');
|
const SystemChannelFlags = require('../util/SystemChannelFlags');
|
||||||
const Util = require('../util/Util');
|
const Util = require('../util/Util');
|
||||||
@@ -241,7 +240,7 @@ class Guild extends AnonymousGuild {
|
|||||||
* The premium tier of this guild
|
* The premium tier of this guild
|
||||||
* @type {PremiumTier}
|
* @type {PremiumTier}
|
||||||
*/
|
*/
|
||||||
this.premiumTier = PremiumTiers[data.premium_tier];
|
this.premiumTier = GuildPremiumTier[data.premium_tier];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('premium_subscription_count' in data) {
|
if ('premium_subscription_count' in data) {
|
||||||
@@ -273,7 +272,7 @@ class Guild extends AnonymousGuild {
|
|||||||
* The explicit content filter level of the guild
|
* The explicit content filter level of the guild
|
||||||
* @type {ExplicitContentFilterLevel}
|
* @type {ExplicitContentFilterLevel}
|
||||||
*/
|
*/
|
||||||
this.explicitContentFilter = ExplicitContentFilterLevels[data.explicit_content_filter];
|
this.explicitContentFilter = GuildExplicitContentFilter[data.explicit_content_filter];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('mfa_level' in data) {
|
if ('mfa_level' in data) {
|
||||||
@@ -281,7 +280,7 @@ class Guild extends AnonymousGuild {
|
|||||||
* The required MFA level for this guild
|
* The required MFA level for this guild
|
||||||
* @type {MFALevel}
|
* @type {MFALevel}
|
||||||
*/
|
*/
|
||||||
this.mfaLevel = MFALevels[data.mfa_level];
|
this.mfaLevel = GuildMFALevel[data.mfa_level];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('joined_at' in data) {
|
if ('joined_at' in data) {
|
||||||
@@ -295,9 +294,9 @@ class Guild extends AnonymousGuild {
|
|||||||
if ('default_message_notifications' in data) {
|
if ('default_message_notifications' in data) {
|
||||||
/**
|
/**
|
||||||
* The default message notification level of the guild
|
* 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) {
|
if ('system_channel_flags' in data) {
|
||||||
@@ -567,12 +566,12 @@ class Guild extends AnonymousGuild {
|
|||||||
return 384_000;
|
return 384_000;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (PremiumTiers[this.premiumTier]) {
|
switch (GuildPremiumTier[this.premiumTier]) {
|
||||||
case PremiumTiers.TIER_1:
|
case GuildPremiumTier.Tier1:
|
||||||
return 128_000;
|
return 128_000;
|
||||||
case PremiumTiers.TIER_2:
|
case GuildPremiumTier.Tier2:
|
||||||
return 256_000;
|
return 256_000;
|
||||||
case PremiumTiers.TIER_3:
|
case GuildPremiumTier.Tier3:
|
||||||
return 384_000;
|
return 384_000;
|
||||||
default:
|
default:
|
||||||
return 96_000;
|
return 96_000;
|
||||||
@@ -821,7 +820,7 @@ class Guild extends AnonymousGuild {
|
|||||||
_data.verification_level =
|
_data.verification_level =
|
||||||
typeof data.verificationLevel === 'number'
|
typeof data.verificationLevel === 'number'
|
||||||
? data.verificationLevel
|
? data.verificationLevel
|
||||||
: VerificationLevels[data.verificationLevel];
|
: GuildVerificationLevel[data.verificationLevel];
|
||||||
}
|
}
|
||||||
if (typeof data.afkChannel !== 'undefined') {
|
if (typeof data.afkChannel !== 'undefined') {
|
||||||
_data.afk_channel_id = this.client.channels.resolveId(data.afkChannel);
|
_data.afk_channel_id = this.client.channels.resolveId(data.afkChannel);
|
||||||
@@ -841,13 +840,13 @@ class Guild extends AnonymousGuild {
|
|||||||
_data.explicit_content_filter =
|
_data.explicit_content_filter =
|
||||||
typeof data.explicitContentFilter === 'number'
|
typeof data.explicitContentFilter === 'number'
|
||||||
? data.explicitContentFilter
|
? data.explicitContentFilter
|
||||||
: ExplicitContentFilterLevels[data.explicitContentFilter];
|
: GuildExplicitContentFilter[data.explicitContentFilter];
|
||||||
}
|
}
|
||||||
if (typeof data.defaultMessageNotifications !== 'undefined') {
|
if (typeof data.defaultMessageNotifications !== 'undefined') {
|
||||||
_data.default_message_notifications =
|
_data.default_message_notifications =
|
||||||
typeof data.defaultMessageNotifications === 'number'
|
typeof data.defaultMessageNotifications === 'number'
|
||||||
? data.defaultMessageNotifications
|
? data.defaultMessageNotifications
|
||||||
: DefaultMessageNotificationLevels[data.defaultMessageNotifications];
|
: GuildDefaultMessageNotifications[data.defaultMessageNotifications];
|
||||||
}
|
}
|
||||||
if (typeof data.systemChannelFlags !== 'undefined') {
|
if (typeof data.systemChannelFlags !== 'undefined') {
|
||||||
_data.system_channel_flags = SystemChannelFlags.resolve(data.systemChannelFlags);
|
_data.system_channel_flags = SystemChannelFlags.resolve(data.systemChannelFlags);
|
||||||
@@ -1303,7 +1302,7 @@ class Guild extends AnonymousGuild {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_sortedChannels(channel) {
|
_sortedChannels(channel) {
|
||||||
const category = channel.type === ChannelTypes.GUILD_CATEGORY;
|
const category = channel.type === ChannelType.GuildCategory;
|
||||||
return Util.discordSort(
|
return Util.discordSort(
|
||||||
this.channels.cache.filter(
|
this.channels.cache.filter(
|
||||||
c =>
|
c =>
|
||||||
|
|||||||
@@ -2,13 +2,14 @@
|
|||||||
|
|
||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||||
|
const { OverwriteType, AuditLogEvent } = require('discord-api-types/v9');
|
||||||
const { GuildScheduledEvent } = require('./GuildScheduledEvent');
|
const { GuildScheduledEvent } = require('./GuildScheduledEvent');
|
||||||
const Integration = require('./Integration');
|
const Integration = require('./Integration');
|
||||||
const Invite = require('./Invite');
|
const Invite = require('./Invite');
|
||||||
const { StageInstance } = require('./StageInstance');
|
const { StageInstance } = require('./StageInstance');
|
||||||
const { Sticker } = require('./Sticker');
|
const { Sticker } = require('./Sticker');
|
||||||
const Webhook = require('./Webhook');
|
const Webhook = require('./Webhook');
|
||||||
const { OverwriteTypes, PartialTypes } = require('../util/Constants');
|
const { PartialTypes } = require('../util/Constants');
|
||||||
const Util = require('../util/Util');
|
const Util = require('../util/Util');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,116 +53,6 @@ const Targets = {
|
|||||||
UNKNOWN: 'UNKNOWN',
|
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.
|
* Audit logs entries are held in this class.
|
||||||
*/
|
*/
|
||||||
@@ -274,20 +165,20 @@ class GuildAuditLogs {
|
|||||||
static actionType(action) {
|
static actionType(action) {
|
||||||
if (
|
if (
|
||||||
[
|
[
|
||||||
Actions.CHANNEL_CREATE,
|
AuditLogEvent.ChannelCreate,
|
||||||
Actions.CHANNEL_OVERWRITE_CREATE,
|
AuditLogEvent.ChannelOverwriteCreate,
|
||||||
Actions.MEMBER_BAN_REMOVE,
|
AuditLogEvent.MemberBanRemove,
|
||||||
Actions.BOT_ADD,
|
AuditLogEvent.BotAdd,
|
||||||
Actions.ROLE_CREATE,
|
AuditLogEvent.RoleCreate,
|
||||||
Actions.INVITE_CREATE,
|
AuditLogEvent.InviteCreate,
|
||||||
Actions.WEBHOOK_CREATE,
|
AuditLogEvent.WebhookCreate,
|
||||||
Actions.EMOJI_CREATE,
|
AuditLogEvent.EmojiCreate,
|
||||||
Actions.MESSAGE_PIN,
|
AuditLogEvent.MessagePin,
|
||||||
Actions.INTEGRATION_CREATE,
|
AuditLogEvent.IntegrationCreate,
|
||||||
Actions.STAGE_INSTANCE_CREATE,
|
AuditLogEvent.StageInstanceCreate,
|
||||||
Actions.STICKER_CREATE,
|
AuditLogEvent.StickerCreate,
|
||||||
Actions.GUILD_SCHEDULED_EVENT_CREATE,
|
AuditLogEvent.GuildScheduledEventCreate,
|
||||||
Actions.THREAD_CREATE,
|
AuditLogEvent.ThreadCreate,
|
||||||
].includes(action)
|
].includes(action)
|
||||||
) {
|
) {
|
||||||
return 'CREATE';
|
return 'CREATE';
|
||||||
@@ -295,24 +186,24 @@ class GuildAuditLogs {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
[
|
[
|
||||||
Actions.CHANNEL_DELETE,
|
AuditLogEvent.ChannelDelete,
|
||||||
Actions.CHANNEL_OVERWRITE_DELETE,
|
AuditLogEvent.ChannelOverwriteDelete,
|
||||||
Actions.MEMBER_KICK,
|
AuditLogEvent.MemberKick,
|
||||||
Actions.MEMBER_PRUNE,
|
AuditLogEvent.MemberPrune,
|
||||||
Actions.MEMBER_BAN_ADD,
|
AuditLogEvent.MemberBanAdd,
|
||||||
Actions.MEMBER_DISCONNECT,
|
AuditLogEvent.MemberDisconnect,
|
||||||
Actions.ROLE_DELETE,
|
AuditLogEvent.RoleDelete,
|
||||||
Actions.INVITE_DELETE,
|
AuditLogEvent.InviteDelete,
|
||||||
Actions.WEBHOOK_DELETE,
|
AuditLogEvent.WebhookDelete,
|
||||||
Actions.EMOJI_DELETE,
|
AuditLogEvent.EmojiDelete,
|
||||||
Actions.MESSAGE_DELETE,
|
AuditLogEvent.MessageDelete,
|
||||||
Actions.MESSAGE_BULK_DELETE,
|
AuditLogEvent.MessageBulkDelete,
|
||||||
Actions.MESSAGE_UNPIN,
|
AuditLogEvent.MessageUnpin,
|
||||||
Actions.INTEGRATION_DELETE,
|
AuditLogEvent.IntegrationDelete,
|
||||||
Actions.STAGE_INSTANCE_DELETE,
|
AuditLogEvent.StageInstanceDelete,
|
||||||
Actions.STICKER_DELETE,
|
AuditLogEvent.StickerDelete,
|
||||||
Actions.GUILD_SCHEDULED_EVENT_DELETE,
|
AuditLogEvent.GuildScheduledEventDelete,
|
||||||
Actions.THREAD_DELETE,
|
AuditLogEvent.ThreadDelete,
|
||||||
].includes(action)
|
].includes(action)
|
||||||
) {
|
) {
|
||||||
return 'DELETE';
|
return 'DELETE';
|
||||||
@@ -320,21 +211,21 @@ class GuildAuditLogs {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
[
|
[
|
||||||
Actions.GUILD_UPDATE,
|
AuditLogEvent.GuildUpdate,
|
||||||
Actions.CHANNEL_UPDATE,
|
AuditLogEvent.ChannelUpdate,
|
||||||
Actions.CHANNEL_OVERWRITE_UPDATE,
|
AuditLogEvent.ChannelOverwriteUpdate,
|
||||||
Actions.MEMBER_UPDATE,
|
AuditLogEvent.MemberUpdate,
|
||||||
Actions.MEMBER_ROLE_UPDATE,
|
AuditLogEvent.MemberRoleUpdate,
|
||||||
Actions.MEMBER_MOVE,
|
AuditLogEvent.MemberMove,
|
||||||
Actions.ROLE_UPDATE,
|
AuditLogEvent.RoleUpdate,
|
||||||
Actions.INVITE_UPDATE,
|
AuditLogEvent.InviteUpdate,
|
||||||
Actions.WEBHOOK_UPDATE,
|
AuditLogEvent.WebhookUpdate,
|
||||||
Actions.EMOJI_UPDATE,
|
AuditLogEvent.EmojiUpdate,
|
||||||
Actions.INTEGRATION_UPDATE,
|
AuditLogEvent.IntegrationUpdate,
|
||||||
Actions.STAGE_INSTANCE_UPDATE,
|
AuditLogEvent.StageInstanceUpdate,
|
||||||
Actions.STICKER_UPDATE,
|
AuditLogEvent.StickerUpdate,
|
||||||
Actions.GUILD_SCHEDULED_EVENT_UPDATE,
|
AuditLogEvent.GuildScheduledEventUpdate,
|
||||||
Actions.THREAD_UPDATE,
|
AuditLogEvent.ThreadUpdate,
|
||||||
].includes(action)
|
].includes(action)
|
||||||
) {
|
) {
|
||||||
return 'UPDATE';
|
return 'UPDATE';
|
||||||
@@ -370,7 +261,7 @@ class GuildAuditLogsEntry {
|
|||||||
* Specific action type of this entry in its string presentation
|
* Specific action type of this entry in its string presentation
|
||||||
* @type {AuditLogAction}
|
* @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
|
* The reason of this entry
|
||||||
@@ -414,52 +305,52 @@ class GuildAuditLogsEntry {
|
|||||||
*/
|
*/
|
||||||
this.extra = null;
|
this.extra = null;
|
||||||
switch (data.action_type) {
|
switch (data.action_type) {
|
||||||
case Actions.MEMBER_PRUNE:
|
case AuditLogEvent.MemberPrune:
|
||||||
this.extra = {
|
this.extra = {
|
||||||
removed: Number(data.options.members_removed),
|
removed: Number(data.options.members_removed),
|
||||||
days: Number(data.options.delete_member_days),
|
days: Number(data.options.delete_member_days),
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Actions.MEMBER_MOVE:
|
case AuditLogEvent.MemberMove:
|
||||||
case Actions.MESSAGE_DELETE:
|
case AuditLogEvent.MessageDelete:
|
||||||
case Actions.MESSAGE_BULK_DELETE:
|
case AuditLogEvent.MessageBulkDelete:
|
||||||
this.extra = {
|
this.extra = {
|
||||||
channel: guild.channels.cache.get(data.options.channel_id) ?? { id: data.options.channel_id },
|
channel: guild.channels.cache.get(data.options.channel_id) ?? { id: data.options.channel_id },
|
||||||
count: Number(data.options.count),
|
count: Number(data.options.count),
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Actions.MESSAGE_PIN:
|
case AuditLogEvent.MessagePin:
|
||||||
case Actions.MESSAGE_UNPIN:
|
case AuditLogEvent.MessageUnpin:
|
||||||
this.extra = {
|
this.extra = {
|
||||||
channel: guild.client.channels.cache.get(data.options.channel_id) ?? { id: data.options.channel_id },
|
channel: guild.client.channels.cache.get(data.options.channel_id) ?? { id: data.options.channel_id },
|
||||||
messageId: data.options.message_id,
|
messageId: data.options.message_id,
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Actions.MEMBER_DISCONNECT:
|
case AuditLogEvent.MemberDisconnect:
|
||||||
this.extra = {
|
this.extra = {
|
||||||
count: Number(data.options.count),
|
count: Number(data.options.count),
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Actions.CHANNEL_OVERWRITE_CREATE:
|
case AuditLogEvent.ChannelOverwriteCreate:
|
||||||
case Actions.CHANNEL_OVERWRITE_UPDATE:
|
case AuditLogEvent.ChannelOverwriteUpdate:
|
||||||
case Actions.CHANNEL_OVERWRITE_DELETE:
|
case AuditLogEvent.ChannelOverwriteDelete:
|
||||||
switch (Number(data.options.type)) {
|
switch (Number(data.options.type)) {
|
||||||
case OverwriteTypes.role:
|
case OverwriteType.Role:
|
||||||
this.extra = guild.roles.cache.get(data.options.id) ?? {
|
this.extra = guild.roles.cache.get(data.options.id) ?? {
|
||||||
id: data.options.id,
|
id: data.options.id,
|
||||||
name: data.options.role_name,
|
name: data.options.role_name,
|
||||||
type: OverwriteTypes[OverwriteTypes.role],
|
type: OverwriteType[OverwriteType.Role],
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OverwriteTypes.member:
|
case OverwriteType.Member:
|
||||||
this.extra = guild.members.cache.get(data.options.id) ?? {
|
this.extra = guild.members.cache.get(data.options.id) ?? {
|
||||||
id: data.options.id,
|
id: data.options.id,
|
||||||
type: OverwriteTypes[OverwriteTypes.member],
|
type: OverwriteType[OverwriteType.Member],
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -468,9 +359,9 @@ class GuildAuditLogsEntry {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Actions.STAGE_INSTANCE_CREATE:
|
case AuditLogEvent.StageInstanceCreate:
|
||||||
case Actions.STAGE_INSTANCE_DELETE:
|
case AuditLogEvent.StageInstanceDelete:
|
||||||
case Actions.STAGE_INSTANCE_UPDATE:
|
case AuditLogEvent.StageInstanceUpdate:
|
||||||
this.extra = {
|
this.extra = {
|
||||||
channel: guild.client.channels.cache.get(data.options?.channel_id) ?? { id: data.options?.channel_id },
|
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) {
|
} else if (targetType === Targets.MESSAGE) {
|
||||||
// Discord sends a channel id for the MESSAGE_BULK_DELETE action type.
|
// Discord sends a channel id for the MESSAGE_BULK_DELETE action type.
|
||||||
this.target =
|
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.channels.cache.get(data.target_id) ?? { id: data.target_id }
|
||||||
: guild.client.users.cache.get(data.target_id);
|
: guild.client.users.cache.get(data.target_id);
|
||||||
} else if (targetType === Targets.INTEGRATION) {
|
} else if (targetType === Targets.INTEGRATION) {
|
||||||
@@ -631,7 +522,6 @@ class GuildAuditLogsEntry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GuildAuditLogs.Actions = Actions;
|
|
||||||
GuildAuditLogs.Targets = Targets;
|
GuildAuditLogs.Targets = Targets;
|
||||||
GuildAuditLogs.Entry = GuildAuditLogsEntry;
|
GuildAuditLogs.Entry = GuildAuditLogsEntry;
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { ChannelType } = require('discord-api-types/v9');
|
||||||
const { Channel } = require('./Channel');
|
const { Channel } = require('./Channel');
|
||||||
const PermissionOverwrites = require('./PermissionOverwrites');
|
const PermissionOverwrites = require('./PermissionOverwrites');
|
||||||
const { Error } = require('../errors');
|
const { Error } = require('../errors');
|
||||||
const PermissionOverwriteManager = require('../managers/PermissionOverwriteManager');
|
const PermissionOverwriteManager = require('../managers/PermissionOverwriteManager');
|
||||||
const { ChannelTypes, VoiceBasedChannelTypes } = require('../util/Constants');
|
const { VoiceBasedChannelTypes } = require('../util/Constants');
|
||||||
const Permissions = require('../util/Permissions');
|
const Permissions = require('../util/Permissions');
|
||||||
const Util = require('../util/Util');
|
const Util = require('../util/Util');
|
||||||
|
|
||||||
@@ -321,7 +322,7 @@ class GuildChannel extends Channel {
|
|||||||
if (data.lockPermissions) {
|
if (data.lockPermissions) {
|
||||||
if (data.parent) {
|
if (data.parent) {
|
||||||
const newParent = this.guild.channels.resolve(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 =>
|
permission_overwrites = newParent.permissionOverwrites.cache.map(o =>
|
||||||
PermissionOverwrites.resolve(o, this.guild),
|
PermissionOverwrites.resolve(o, this.guild),
|
||||||
);
|
);
|
||||||
@@ -336,7 +337,7 @@ class GuildChannel extends Channel {
|
|||||||
const newData = await this.client.api.channels(this.id).patch({
|
const newData = await this.client.api.channels(this.id).patch({
|
||||||
data: {
|
data: {
|
||||||
name: (data.name ?? this.name).trim(),
|
name: (data.name ?? this.name).trim(),
|
||||||
type: ChannelTypes[data.type],
|
type: ChannelType[data.type],
|
||||||
topic: data.topic,
|
topic: data.topic,
|
||||||
nsfw: data.nsfw,
|
nsfw: data.nsfw,
|
||||||
bitrate: data.bitrate ?? this.bitrate,
|
bitrate: data.bitrate ?? this.bitrate,
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||||
|
const {
|
||||||
|
GuildScheduledEventPrivacyLevel,
|
||||||
|
GuildScheduledEventStatus,
|
||||||
|
GuildScheduledEventEntityType,
|
||||||
|
} = require('discord-api-types/v9');
|
||||||
const Base = require('./Base');
|
const Base = require('./Base');
|
||||||
const { Error } = require('../errors');
|
const { Error } = require('../errors');
|
||||||
const {
|
const { Endpoints } = require('../util/Constants');
|
||||||
GuildScheduledEventEntityTypes,
|
|
||||||
GuildScheduledEventStatuses,
|
|
||||||
GuildScheduledEventPrivacyLevels,
|
|
||||||
Endpoints,
|
|
||||||
} = require('../util/Constants');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a scheduled event in a {@link Guild}.
|
* Represents a scheduled event in a {@link Guild}.
|
||||||
@@ -88,19 +88,19 @@ class GuildScheduledEvent extends Base {
|
|||||||
* The privacy level of the guild scheduled event
|
* The privacy level of the guild scheduled event
|
||||||
* @type {PrivacyLevel}
|
* @type {PrivacyLevel}
|
||||||
*/
|
*/
|
||||||
this.privacyLevel = GuildScheduledEventPrivacyLevels[data.privacy_level];
|
this.privacyLevel = GuildScheduledEventPrivacyLevel[data.privacy_level];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The status of the guild scheduled event
|
* The status of the guild scheduled event
|
||||||
* @type {GuildScheduledEventStatus}
|
* @type {GuildScheduledEventStatus}
|
||||||
*/
|
*/
|
||||||
this.status = GuildScheduledEventStatuses[data.status];
|
this.status = GuildScheduledEventStatus[data.status];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of hosting entity associated with the scheduled event
|
* The type of hosting entity associated with the scheduled event
|
||||||
* @type {GuildScheduledEventEntityType}
|
* @type {GuildScheduledEventEntityType}
|
||||||
*/
|
*/
|
||||||
this.entityType = GuildScheduledEventEntityTypes[data.entity_type];
|
this.entityType = GuildScheduledEventEntityType[data.entity_type];
|
||||||
|
|
||||||
if ('entity_id' in data) {
|
if ('entity_id' in data) {
|
||||||
/**
|
/**
|
||||||
@@ -391,7 +391,7 @@ class GuildScheduledEvent extends Base {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isActive() {
|
isActive() {
|
||||||
return GuildScheduledEventStatuses[this.status] === GuildScheduledEventStatuses.ACTIVE;
|
return GuildScheduledEventStatus[this.status] === GuildScheduledEventStatus.Active;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -399,7 +399,7 @@ class GuildScheduledEvent extends Base {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isCanceled() {
|
isCanceled() {
|
||||||
return GuildScheduledEventStatuses[this.status] === GuildScheduledEventStatuses.CANCELED;
|
return GuildScheduledEventStatus[this.status] === GuildScheduledEventStatus.Canceled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -407,7 +407,7 @@ class GuildScheduledEvent extends Base {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isCompleted() {
|
isCompleted() {
|
||||||
return GuildScheduledEventStatuses[this.status] === GuildScheduledEventStatuses.COMPLETED;
|
return GuildScheduledEventStatus[this.status] === GuildScheduledEventStatus.Completed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -415,7 +415,7 @@ class GuildScheduledEvent extends Base {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isScheduled() {
|
isScheduled() {
|
||||||
return GuildScheduledEventStatuses[this.status] === GuildScheduledEventStatuses.SCHEDULED;
|
return GuildScheduledEventStatus[this.status] === GuildScheduledEventStatus.Scheduled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||||
|
const { InteractionType, ApplicationCommandType, ComponentType } = require('discord-api-types/v9');
|
||||||
const Base = require('./Base');
|
const Base = require('./Base');
|
||||||
const { InteractionTypes, MessageComponentTypes, ApplicationCommandTypes } = require('../util/Constants');
|
|
||||||
const Permissions = require('../util/Permissions');
|
const Permissions = require('../util/Permissions');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,7 +17,7 @@ class Interaction extends Base {
|
|||||||
* The interaction's type
|
* The interaction's type
|
||||||
* @type {InteractionType}
|
* @type {InteractionType}
|
||||||
*/
|
*/
|
||||||
this.type = InteractionTypes[data.type];
|
this.type = InteractionType[data.type];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The interaction's id
|
* The interaction's id
|
||||||
@@ -153,7 +153,7 @@ class Interaction extends Base {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isCommand() {
|
isCommand() {
|
||||||
return InteractionTypes[this.type] === InteractionTypes.APPLICATION_COMMAND;
|
return InteractionType[this.type] === InteractionType.ApplicationCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -161,7 +161,7 @@ class Interaction extends Base {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isChatInputCommand() {
|
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}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isContextMenuCommand() {
|
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}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isUserContextMenuCommand() {
|
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}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isMessageContextMenuCommand() {
|
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}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isAutocomplete() {
|
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}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isMessageComponent() {
|
isMessageComponent() {
|
||||||
return InteractionTypes[this.type] === InteractionTypes.MESSAGE_COMPONENT;
|
return InteractionType[this.type] === InteractionType.MessageComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -210,8 +210,8 @@ class Interaction extends Base {
|
|||||||
*/
|
*/
|
||||||
isButton() {
|
isButton() {
|
||||||
return (
|
return (
|
||||||
InteractionTypes[this.type] === InteractionTypes.MESSAGE_COMPONENT &&
|
InteractionType[this.type] === InteractionType.MessageComponent &&
|
||||||
MessageComponentTypes[this.componentType] === MessageComponentTypes.BUTTON
|
ComponentType[this.componentType] === ComponentType.Button
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,8 +221,8 @@ class Interaction extends Base {
|
|||||||
*/
|
*/
|
||||||
isSelectMenu() {
|
isSelectMenu() {
|
||||||
return (
|
return (
|
||||||
InteractionTypes[this.type] === InteractionTypes.MESSAGE_COMPONENT &&
|
InteractionType[this.type] === InteractionType.MessageComponent &&
|
||||||
MessageComponentTypes[this.componentType] === MessageComponentTypes.SELECT_MENU
|
ComponentType[this.componentType] === ComponentType.SelectMenu
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
|
const { InteractionType, ComponentType } = require('discord-api-types/v9');
|
||||||
const Collector = require('./interfaces/Collector');
|
const Collector = require('./interfaces/Collector');
|
||||||
const { Events } = require('../util/Constants');
|
const { Events } = require('../util/Constants');
|
||||||
const { InteractionTypes, MessageComponentTypes } = require('../util/Constants');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {CollectorOptions} InteractionCollectorOptions
|
* @typedef {CollectorOptions} InteractionCollectorOptions
|
||||||
@@ -66,7 +66,7 @@ class InteractionCollector extends Collector {
|
|||||||
*/
|
*/
|
||||||
this.interactionType =
|
this.interactionType =
|
||||||
typeof options.interactionType === 'number'
|
typeof options.interactionType === 'number'
|
||||||
? InteractionTypes[options.interactionType]
|
? InteractionType[options.interactionType]
|
||||||
: options.interactionType ?? null;
|
: options.interactionType ?? null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,9 +74,7 @@ class InteractionCollector extends Collector {
|
|||||||
* @type {?MessageComponentType}
|
* @type {?MessageComponentType}
|
||||||
*/
|
*/
|
||||||
this.componentType =
|
this.componentType =
|
||||||
typeof options.componentType === 'number'
|
typeof options.componentType === 'number' ? ComponentType[options.componentType] : options.componentType ?? null;
|
||||||
? MessageComponentTypes[options.componentType]
|
|
||||||
: options.componentType ?? null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The users that have interacted with this collector
|
* The users that have interacted with this collector
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||||
|
const { MessageType, InteractionType } = require('discord-api-types/v9');
|
||||||
const Base = require('./Base');
|
const Base = require('./Base');
|
||||||
const BaseMessageComponent = require('./BaseMessageComponent');
|
const BaseMessageComponent = require('./BaseMessageComponent');
|
||||||
const ClientApplication = require('./ClientApplication');
|
const ClientApplication = require('./ClientApplication');
|
||||||
@@ -14,7 +15,7 @@ const ReactionCollector = require('./ReactionCollector');
|
|||||||
const { Sticker } = require('./Sticker');
|
const { Sticker } = require('./Sticker');
|
||||||
const { Error } = require('../errors');
|
const { Error } = require('../errors');
|
||||||
const ReactionManager = require('../managers/ReactionManager');
|
const ReactionManager = require('../managers/ReactionManager');
|
||||||
const { InteractionTypes, MessageTypes, SystemMessageTypes } = require('../util/Constants');
|
const { SystemMessageTypes } = require('../util/Constants');
|
||||||
const MessageFlags = require('../util/MessageFlags');
|
const MessageFlags = require('../util/MessageFlags');
|
||||||
const Permissions = require('../util/Permissions');
|
const Permissions = require('../util/Permissions');
|
||||||
const Util = require('../util/Util');
|
const Util = require('../util/Util');
|
||||||
@@ -60,7 +61,7 @@ class Message extends Base {
|
|||||||
* The type of the message
|
* The type of the message
|
||||||
* @type {?MessageType}
|
* @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)
|
* 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 = {
|
this.interaction = {
|
||||||
id: data.interaction.id,
|
id: data.interaction.id,
|
||||||
type: InteractionTypes[data.interaction.type],
|
type: InteractionType[data.interaction.type],
|
||||||
commandName: data.interaction.name,
|
commandName: data.interaction.name,
|
||||||
user: this.client.users._add(data.interaction.user),
|
user: this.client.users._add(data.interaction.user),
|
||||||
};
|
};
|
||||||
@@ -502,7 +503,7 @@ class Message extends Base {
|
|||||||
createMessageComponentCollector(options = {}) {
|
createMessageComponentCollector(options = {}) {
|
||||||
return new InteractionCollector(this.client, {
|
return new InteractionCollector(this.client, {
|
||||||
...options,
|
...options,
|
||||||
interactionType: InteractionTypes.MESSAGE_COMPONENT,
|
interactionType: InteractionType.MessageComponent,
|
||||||
message: this,
|
message: this,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { ComponentType } = require('discord-api-types/v9');
|
||||||
const Interaction = require('./Interaction');
|
const Interaction = require('./Interaction');
|
||||||
const InteractionWebhook = require('./InteractionWebhook');
|
const InteractionWebhook = require('./InteractionWebhook');
|
||||||
const InteractionResponses = require('./interfaces/InteractionResponses');
|
const InteractionResponses = require('./interfaces/InteractionResponses');
|
||||||
const { MessageComponentTypes } = require('../util/Constants');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a message component interaction.
|
* Represents a message component interaction.
|
||||||
@@ -84,11 +84,11 @@ class MessageComponentInteraction extends Interaction {
|
|||||||
/**
|
/**
|
||||||
* Resolves the type of a MessageComponent
|
* Resolves the type of a MessageComponent
|
||||||
* @param {MessageComponentTypeResolvable} type The type to resolve
|
* @param {MessageComponentTypeResolvable} type The type to resolve
|
||||||
* @returns {MessageComponentType}
|
* @returns {ComponentType}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
static resolveType(type) {
|
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
|
// These are here only for documentation purposes - they are implemented by InteractionResponses
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
const { ChannelTypes } = require('../util/Constants');
|
const { ChannelType } = require('discord-api-types/v9');
|
||||||
const Util = require('../util/Util');
|
const Util = require('../util/Util');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -112,7 +112,7 @@ class MessageMentions {
|
|||||||
this.crosspostedChannels = new Collection(crosspostedChannels);
|
this.crosspostedChannels = new Collection(crosspostedChannels);
|
||||||
} else {
|
} else {
|
||||||
this.crosspostedChannels = new Collection();
|
this.crosspostedChannels = new Collection();
|
||||||
const channelTypes = Object.keys(ChannelTypes);
|
const channelTypes = Object.keys(ChannelType);
|
||||||
for (const d of crosspostedChannels) {
|
for (const d of crosspostedChannels) {
|
||||||
const type = channelTypes[d.type];
|
const type = channelTypes[d.type];
|
||||||
this.crosspostedChannels.set(d.id, {
|
this.crosspostedChannels.set(d.id, {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { OverwriteType } = require('discord-api-types/v9');
|
||||||
const Base = require('./Base');
|
const Base = require('./Base');
|
||||||
const { Role } = require('./Role');
|
const { Role } = require('./Role');
|
||||||
const { TypeError } = require('../errors');
|
const { TypeError } = require('../errors');
|
||||||
const { OverwriteTypes } = require('../util/Constants');
|
|
||||||
const Permissions = require('../util/Permissions');
|
const Permissions = require('../util/Permissions');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,7 +37,7 @@ class PermissionOverwrites extends Base {
|
|||||||
* The type of this overwrite
|
* The type of this overwrite
|
||||||
* @type {OverwriteType}
|
* @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) {
|
if ('deny' in data) {
|
||||||
@@ -71,7 +71,7 @@ class PermissionOverwrites extends Base {
|
|||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
async edit(options, reason) {
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ class PermissionOverwrites extends Base {
|
|||||||
toJSON() {
|
toJSON() {
|
||||||
return {
|
return {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
type: OverwriteTypes[this.type],
|
type: OverwriteType[this.type],
|
||||||
allow: this.allow,
|
allow: this.allow,
|
||||||
deny: this.deny,
|
deny: this.deny,
|
||||||
};
|
};
|
||||||
@@ -171,10 +171,10 @@ class PermissionOverwrites extends Base {
|
|||||||
*/
|
*/
|
||||||
static resolve(overwrite, guild) {
|
static resolve(overwrite, guild) {
|
||||||
if (overwrite instanceof this) return overwrite.toJSON();
|
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 {
|
return {
|
||||||
id: overwrite.id,
|
id: overwrite.id,
|
||||||
type: OverwriteTypes[overwrite.type],
|
type: OverwriteType[overwrite.type],
|
||||||
allow: Permissions.resolve(overwrite.allow ?? Permissions.defaultBit).toString(),
|
allow: Permissions.resolve(overwrite.allow ?? Permissions.defaultBit).toString(),
|
||||||
deny: Permissions.resolve(overwrite.deny ?? 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);
|
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');
|
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 {
|
return {
|
||||||
id: userOrRole.id,
|
id: userOrRole.id,
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { ActivityType } = require('discord-api-types/v9');
|
||||||
const Base = require('./Base');
|
const Base = require('./Base');
|
||||||
const { Emoji } = require('./Emoji');
|
const { Emoji } = require('./Emoji');
|
||||||
const ActivityFlags = require('../util/ActivityFlags');
|
const ActivityFlags = require('../util/ActivityFlags');
|
||||||
const { ActivityTypes } = require('../util/Constants');
|
|
||||||
const Util = require('../util/Util');
|
const Util = require('../util/Util');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -168,7 +168,7 @@ class Activity {
|
|||||||
* The activity status's type
|
* The activity status's type
|
||||||
* @type {ActivityType}
|
* @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
|
* If the activity is being streamed, a link to the stream
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||||
|
const { StageInstancePrivacyLevel } = require('discord-api-types/v9');
|
||||||
const Base = require('./Base');
|
const Base = require('./Base');
|
||||||
const { PrivacyLevels } = require('../util/Constants');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a stage instance.
|
* Represents a stage instance.
|
||||||
@@ -49,9 +49,9 @@ class StageInstance extends Base {
|
|||||||
if ('privacy_level' in data) {
|
if ('privacy_level' in data) {
|
||||||
/**
|
/**
|
||||||
* The privacy level of the stage instance
|
* 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) {
|
if ('discoverable_disabled' in data) {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||||
|
const { StickerType, StickerFormatType } = require('discord-api-types/v9');
|
||||||
const Base = require('./Base');
|
const Base = require('./Base');
|
||||||
const { StickerFormatTypes, StickerTypes } = require('../util/Constants');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a Sticker.
|
* Represents a Sticker.
|
||||||
@@ -37,7 +37,7 @@ class Sticker extends Base {
|
|||||||
* The type of the sticker
|
* The type of the sticker
|
||||||
* @type {?StickerType}
|
* @type {?StickerType}
|
||||||
*/
|
*/
|
||||||
this.type = StickerTypes[sticker.type];
|
this.type = StickerType[sticker.type];
|
||||||
} else {
|
} else {
|
||||||
this.type ??= null;
|
this.type ??= null;
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ class Sticker extends Base {
|
|||||||
* The format of the sticker
|
* The format of the sticker
|
||||||
* @type {StickerFormatType}
|
* @type {StickerFormatType}
|
||||||
*/
|
*/
|
||||||
this.format = StickerFormatTypes[sticker.format_type];
|
this.format = StickerFormatType[sticker.format_type];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('name' in sticker) {
|
if ('name' in sticker) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { TeamMemberMembershipState } = require('discord-api-types/v9');
|
||||||
const Base = require('./Base');
|
const Base = require('./Base');
|
||||||
const { MembershipStates } = require('../util/Constants');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a Client OAuth2 Application Team Member.
|
* Represents a Client OAuth2 Application Team Member.
|
||||||
@@ -32,9 +32,9 @@ class TeamMember extends Base {
|
|||||||
if ('membership_state' in data) {
|
if ('membership_state' in data) {
|
||||||
/**
|
/**
|
||||||
* The permissions this Team Member has with regard to the team
|
* 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) {
|
if ('user' in data) {
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
const process = require('node:process');
|
const process = require('node:process');
|
||||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||||
|
const { WebhookType } = require('discord-api-types/v9');
|
||||||
const MessagePayload = require('./MessagePayload');
|
const MessagePayload = require('./MessagePayload');
|
||||||
const { Error } = require('../errors');
|
const { Error } = require('../errors');
|
||||||
const { WebhookTypes } = require('../util/Constants');
|
|
||||||
const DataResolver = require('../util/DataResolver');
|
const DataResolver = require('../util/DataResolver');
|
||||||
|
|
||||||
let deprecationEmittedForFetchMessage = false;
|
let deprecationEmittedForFetchMessage = false;
|
||||||
@@ -59,7 +59,7 @@ class Webhook {
|
|||||||
* The type of the webhook
|
* The type of the webhook
|
||||||
* @type {WebhookType}
|
* @type {WebhookType}
|
||||||
*/
|
*/
|
||||||
this.type = WebhookTypes[data.type];
|
this.type = WebhookType[data.type];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('guild_id' in data) {
|
if ('guild_id' in data) {
|
||||||
@@ -416,7 +416,7 @@ class Webhook {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isChannelFollower() {
|
isChannelFollower() {
|
||||||
return this.type === 'Channel Follower';
|
return this.type === 'ChannelFollower';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { InteractionResponseType } = require('discord-api-types/v9');
|
||||||
const { Error } = require('../../errors');
|
const { Error } = require('../../errors');
|
||||||
const { InteractionResponseTypes } = require('../../util/Constants');
|
|
||||||
const MessageFlags = require('../../util/MessageFlags');
|
const MessageFlags = require('../../util/MessageFlags');
|
||||||
const MessagePayload = require('../MessagePayload');
|
const MessagePayload = require('../MessagePayload');
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ class InteractionResponses {
|
|||||||
this.ephemeral = options.ephemeral ?? false;
|
this.ephemeral = options.ephemeral ?? false;
|
||||||
await this.client.api.interactions(this.id, this.token).callback.post({
|
await this.client.api.interactions(this.id, this.token).callback.post({
|
||||||
data: {
|
data: {
|
||||||
type: InteractionResponseTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE,
|
type: InteractionResponseType.DeferredChannelMessageWithSource,
|
||||||
data: {
|
data: {
|
||||||
flags: options.ephemeral ? MessageFlags.FLAGS.EPHEMERAL : undefined,
|
flags: options.ephemeral ? MessageFlags.FLAGS.EPHEMERAL : undefined,
|
||||||
},
|
},
|
||||||
@@ -98,7 +98,7 @@ class InteractionResponses {
|
|||||||
|
|
||||||
await this.client.api.interactions(this.id, this.token).callback.post({
|
await this.client.api.interactions(this.id, this.token).callback.post({
|
||||||
data: {
|
data: {
|
||||||
type: InteractionResponseTypes.CHANNEL_MESSAGE_WITH_SOURCE,
|
type: InteractionResponseType.ChannelMessageWithSource,
|
||||||
data,
|
data,
|
||||||
},
|
},
|
||||||
files,
|
files,
|
||||||
@@ -180,7 +180,7 @@ class InteractionResponses {
|
|||||||
if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
|
if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
|
||||||
await this.client.api.interactions(this.id, this.token).callback.post({
|
await this.client.api.interactions(this.id, this.token).callback.post({
|
||||||
data: {
|
data: {
|
||||||
type: InteractionResponseTypes.DEFERRED_MESSAGE_UPDATE,
|
type: InteractionResponseType.DeferredMessageUpdate,
|
||||||
},
|
},
|
||||||
auth: false,
|
auth: false,
|
||||||
});
|
});
|
||||||
@@ -213,7 +213,7 @@ class InteractionResponses {
|
|||||||
|
|
||||||
await this.client.api.interactions(this.id, this.token).callback.post({
|
await this.client.api.interactions(this.id, this.token).callback.post({
|
||||||
data: {
|
data: {
|
||||||
type: InteractionResponseTypes.UPDATE_MESSAGE,
|
type: InteractionResponseType.UpdateMessage,
|
||||||
data,
|
data,
|
||||||
},
|
},
|
||||||
files,
|
files,
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ const MessageCollector = require('../MessageCollector');
|
|||||||
const MessagePayload = require('../MessagePayload');
|
const MessagePayload = require('../MessagePayload');
|
||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||||
const { InteractionTypes } = require('../../util/Constants');
|
|
||||||
const { TypeError, Error } = require('../../errors');
|
const { TypeError, Error } = require('../../errors');
|
||||||
|
const { InteractionType } = require('discord-api-types/v9');
|
||||||
const InteractionCollector = require('../InteractionCollector');
|
const InteractionCollector = require('../InteractionCollector');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -249,7 +249,7 @@ class TextBasedChannel {
|
|||||||
createMessageComponentCollector(options = {}) {
|
createMessageComponentCollector(options = {}) {
|
||||||
return new InteractionCollector(this.client, {
|
return new InteractionCollector(this.client, {
|
||||||
...options,
|
...options,
|
||||||
interactionType: InteractionTypes.MESSAGE_COMPONENT,
|
interactionType: InteractionType.MessageComponent,
|
||||||
channel: this,
|
channel: this,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -478,56 +478,6 @@ exports.SystemMessageTypes = exports.MessageTypes.filter(
|
|||||||
type => type && !['DEFAULT', 'REPLY', 'CHAT_INPUT_COMMAND', 'CONTEXT_MENU_COMMAND'].includes(type),
|
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.
|
* The channels that are text-based.
|
||||||
* * DMChannel
|
* * DMChannel
|
||||||
@@ -606,558 +556,6 @@ exports.Colors = {
|
|||||||
NOT_QUITE_BLACK: 0x23272a,
|
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 */
|
/* eslint-enable max-len */
|
||||||
|
|
||||||
function keyMirror(arr) {
|
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.
|
* @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 {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.
|
* @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,
|
APIRole,
|
||||||
APIButtonComponent,
|
APIButtonComponent,
|
||||||
APISelectMenuComponent,
|
APISelectMenuComponent,
|
||||||
|
ApplicationCommandOptionType,
|
||||||
} from 'discord-api-types/v9';
|
} from 'discord-api-types/v9';
|
||||||
import { AuditLogEvent } from 'discord-api-types/v9';
|
import { AuditLogEvent } from 'discord-api-types/v9';
|
||||||
import {
|
import {
|
||||||
@@ -91,7 +92,6 @@ import {
|
|||||||
MessageSelectMenu,
|
MessageSelectMenu,
|
||||||
PartialDMChannel,
|
PartialDMChannel,
|
||||||
} from '.';
|
} from '.';
|
||||||
import type { ApplicationCommandOptionTypes } from './enums';
|
|
||||||
import { expectAssignable, expectDeprecated, expectNotAssignable, expectNotType, expectType } from 'tsd';
|
import { expectAssignable, expectDeprecated, expectNotAssignable, expectNotType, expectType } from 'tsd';
|
||||||
|
|
||||||
// Test type transformation:
|
// Test type transformation:
|
||||||
@@ -144,7 +144,7 @@ client.on('ready', async () => {
|
|||||||
await globalPermissionsManager?.add({
|
await globalPermissionsManager?.add({
|
||||||
command: globalCommandId,
|
command: globalCommandId,
|
||||||
guild: testGuildId,
|
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?.has({ command: globalCommandId, guild: testGuildId, permissionId: testGuildId });
|
||||||
await globalPermissionsManager?.fetch({ guild: testGuildId });
|
await globalPermissionsManager?.fetch({ guild: testGuildId });
|
||||||
@@ -160,17 +160,17 @@ client.on('ready', async () => {
|
|||||||
await globalPermissionsManager?.set({
|
await globalPermissionsManager?.set({
|
||||||
command: globalCommandId,
|
command: globalCommandId,
|
||||||
guild: testGuildId,
|
guild: testGuildId,
|
||||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||||
});
|
});
|
||||||
await globalPermissionsManager?.set({
|
await globalPermissionsManager?.set({
|
||||||
guild: testGuildId,
|
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
|
// @ts-expect-error
|
||||||
await globalPermissionsManager?.add({
|
await globalPermissionsManager?.add({
|
||||||
command: globalCommandId,
|
command: globalCommandId,
|
||||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||||
});
|
});
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
await globalPermissionsManager?.has({ command: globalCommandId, permissionId: testGuildId });
|
await globalPermissionsManager?.has({ command: globalCommandId, permissionId: testGuildId });
|
||||||
@@ -187,23 +187,23 @@ client.on('ready', async () => {
|
|||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
await globalPermissionsManager?.set({
|
await globalPermissionsManager?.set({
|
||||||
command: globalCommandId,
|
command: globalCommandId,
|
||||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||||
});
|
});
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
await globalPermissionsManager?.set({
|
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
|
// @ts-expect-error
|
||||||
await globalPermissionsManager?.set({
|
await globalPermissionsManager?.set({
|
||||||
command: globalCommandId,
|
command: globalCommandId,
|
||||||
guild: testGuildId,
|
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
|
// @ts-expect-error
|
||||||
await globalPermissionsManager?.add({
|
await globalPermissionsManager?.add({
|
||||||
guild: testGuildId,
|
guild: testGuildId,
|
||||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||||
});
|
});
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
await globalPermissionsManager?.has({ guild: testGuildId, permissionId: testGuildId });
|
await globalPermissionsManager?.has({ guild: testGuildId, permissionId: testGuildId });
|
||||||
@@ -216,13 +216,13 @@ client.on('ready', async () => {
|
|||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
await globalPermissionsManager?.set({
|
await globalPermissionsManager?.set({
|
||||||
guild: testGuildId,
|
guild: testGuildId,
|
||||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||||
});
|
});
|
||||||
|
|
||||||
// Permissions from guild manager
|
// Permissions from guild manager
|
||||||
await guildPermissionsManager?.add({
|
await guildPermissionsManager?.add({
|
||||||
command: globalCommandId,
|
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?.has({ command: globalCommandId, permissionId: testGuildId });
|
||||||
await guildPermissionsManager?.fetch({});
|
await guildPermissionsManager?.fetch({});
|
||||||
@@ -232,17 +232,17 @@ client.on('ready', async () => {
|
|||||||
await guildPermissionsManager?.remove({ command: globalCommandId, roles: [testGuildId], users: [testUserId] });
|
await guildPermissionsManager?.remove({ command: globalCommandId, roles: [testGuildId], users: [testUserId] });
|
||||||
await guildPermissionsManager?.set({
|
await guildPermissionsManager?.set({
|
||||||
command: globalCommandId,
|
command: globalCommandId,
|
||||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||||
});
|
});
|
||||||
await guildPermissionsManager?.set({
|
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({
|
await guildPermissionsManager?.add({
|
||||||
command: globalCommandId,
|
command: globalCommandId,
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
guild: testGuildId,
|
guild: testGuildId,
|
||||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||||
});
|
});
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
await guildPermissionsManager?.has({ command: globalCommandId, guild: testGuildId, permissionId: testGuildId });
|
await guildPermissionsManager?.has({ command: globalCommandId, guild: testGuildId, permissionId: testGuildId });
|
||||||
@@ -265,16 +265,16 @@ client.on('ready', async () => {
|
|||||||
await guildPermissionsManager?.set({
|
await guildPermissionsManager?.set({
|
||||||
command: globalCommandId,
|
command: globalCommandId,
|
||||||
guild: testGuildId,
|
guild: testGuildId,
|
||||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||||
});
|
});
|
||||||
await guildPermissionsManager?.set({
|
await guildPermissionsManager?.set({
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
guild: testGuildId,
|
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
|
// @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
|
// @ts-expect-error
|
||||||
await guildPermissionsManager?.has({ permissionId: testGuildId });
|
await guildPermissionsManager?.has({ permissionId: testGuildId });
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
@@ -284,17 +284,17 @@ client.on('ready', async () => {
|
|||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
await guildPermissionsManager?.remove({ roles: [testGuildId], users: [testUserId] });
|
await guildPermissionsManager?.remove({ roles: [testGuildId], users: [testUserId] });
|
||||||
// @ts-expect-error
|
// @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
|
// @ts-expect-error
|
||||||
await guildPermissionsManager?.set({
|
await guildPermissionsManager?.set({
|
||||||
command: globalCommandId,
|
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
|
// Permissions from cached global ApplicationCommand
|
||||||
await globalCommand?.permissions.add({
|
await globalCommand?.permissions.add({
|
||||||
guild: testGuildId,
|
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.has({ guild: testGuildId, permissionId: testGuildId });
|
||||||
await globalCommand?.permissions.fetch({ guild: 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.remove({ guild: testGuildId, roles: [testGuildId], users: [testUserId] });
|
||||||
await globalCommand?.permissions.set({
|
await globalCommand?.permissions.set({
|
||||||
guild: testGuildId,
|
guild: testGuildId,
|
||||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||||
});
|
});
|
||||||
|
|
||||||
await globalCommand?.permissions.add({
|
await globalCommand?.permissions.add({
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
command: globalCommandId,
|
command: globalCommandId,
|
||||||
guild: testGuildId,
|
guild: testGuildId,
|
||||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||||
});
|
});
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
await globalCommand?.permissions.has({ command: globalCommandId, guild: testGuildId, permissionId: testGuildId });
|
await globalCommand?.permissions.has({ command: globalCommandId, guild: testGuildId, permissionId: testGuildId });
|
||||||
@@ -331,11 +331,11 @@ client.on('ready', async () => {
|
|||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
command: globalCommandId,
|
command: globalCommandId,
|
||||||
guild: testGuildId,
|
guild: testGuildId,
|
||||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||||
});
|
});
|
||||||
|
|
||||||
// @ts-expect-error
|
// @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
|
// @ts-expect-error
|
||||||
await globalCommand?.permissions.has({ permissionId: testGuildId });
|
await globalCommand?.permissions.has({ permissionId: testGuildId });
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
@@ -347,21 +347,21 @@ client.on('ready', async () => {
|
|||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
await globalCommand?.permissions.remove({ roles: [testGuildId], users: [testUserId] });
|
await globalCommand?.permissions.remove({ roles: [testGuildId], users: [testUserId] });
|
||||||
// @ts-expect-error
|
// @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
|
// 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.has({ permissionId: testGuildId });
|
||||||
await guildCommandFromGlobal?.permissions.fetch({});
|
await guildCommandFromGlobal?.permissions.fetch({});
|
||||||
await guildCommandFromGlobal?.permissions.remove({ roles: [testGuildId] });
|
await guildCommandFromGlobal?.permissions.remove({ roles: [testGuildId] });
|
||||||
await guildCommandFromGlobal?.permissions.remove({ users: [testUserId] });
|
await guildCommandFromGlobal?.permissions.remove({ users: [testUserId] });
|
||||||
await guildCommandFromGlobal?.permissions.remove({ roles: [testGuildId], 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({
|
await guildCommandFromGlobal?.permissions.add({
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
command: globalCommandId,
|
command: globalCommandId,
|
||||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||||
});
|
});
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
await guildCommandFromGlobal?.permissions.has({ command: guildCommandId, permissionId: testGuildId });
|
await guildCommandFromGlobal?.permissions.has({ command: guildCommandId, permissionId: testGuildId });
|
||||||
@@ -378,13 +378,13 @@ client.on('ready', async () => {
|
|||||||
await guildCommandFromGlobal?.permissions.set({
|
await guildCommandFromGlobal?.permissions.set({
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
command: guildCommandId,
|
command: guildCommandId,
|
||||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||||
});
|
});
|
||||||
|
|
||||||
await guildCommandFromGlobal?.permissions.add({
|
await guildCommandFromGlobal?.permissions.add({
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
guild: testGuildId,
|
guild: testGuildId,
|
||||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||||
});
|
});
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
await guildCommandFromGlobal?.permissions.has({ guild: testGuildId, permissionId: testGuildId });
|
await guildCommandFromGlobal?.permissions.has({ guild: testGuildId, permissionId: testGuildId });
|
||||||
@@ -397,21 +397,21 @@ client.on('ready', async () => {
|
|||||||
await guildCommandFromGlobal?.permissions.set({
|
await guildCommandFromGlobal?.permissions.set({
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
guild: testGuildId,
|
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.has({ permissionId: testGuildId });
|
||||||
await guildCommandFromGuild?.permissions.fetch({});
|
await guildCommandFromGuild?.permissions.fetch({});
|
||||||
await guildCommandFromGuild?.permissions.remove({ roles: [testGuildId] });
|
await guildCommandFromGuild?.permissions.remove({ roles: [testGuildId] });
|
||||||
await guildCommandFromGuild?.permissions.remove({ users: [testUserId] });
|
await guildCommandFromGuild?.permissions.remove({ users: [testUserId] });
|
||||||
await guildCommandFromGuild?.permissions.remove({ roles: [testGuildId], 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({
|
await guildCommandFromGuild?.permissions.add({
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
command: globalCommandId,
|
command: globalCommandId,
|
||||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||||
});
|
});
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
await guildCommandFromGuild?.permissions.has({ command: guildCommandId, permissionId: testGuildId });
|
await guildCommandFromGuild?.permissions.has({ command: guildCommandId, permissionId: testGuildId });
|
||||||
@@ -428,13 +428,13 @@ client.on('ready', async () => {
|
|||||||
await guildCommandFromGuild?.permissions.set({
|
await guildCommandFromGuild?.permissions.set({
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
command: guildCommandId,
|
command: guildCommandId,
|
||||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||||
});
|
});
|
||||||
|
|
||||||
await guildCommandFromGuild?.permissions.add({
|
await guildCommandFromGuild?.permissions.add({
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
guild: testGuildId,
|
guild: testGuildId,
|
||||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||||
});
|
});
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
await guildCommandFromGuild?.permissions.has({ guild: testGuildId, permissionId: testGuildId });
|
await guildCommandFromGuild?.permissions.has({ guild: testGuildId, permissionId: testGuildId });
|
||||||
@@ -447,7 +447,7 @@ client.on('ready', async () => {
|
|||||||
await guildCommandFromGuild?.permissions.set({
|
await guildCommandFromGuild?.permissions.set({
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
guild: testGuildId,
|
guild: testGuildId,
|
||||||
permissions: [{ type: 'ROLE', id: testGuildId, permission: true }],
|
permissions: [{ type: 'Role', id: testGuildId, permission: true }],
|
||||||
});
|
});
|
||||||
|
|
||||||
client.application?.commands.permissions.set({
|
client.application?.commands.permissions.set({
|
||||||
@@ -526,11 +526,11 @@ client.on('messageCreate', async message => {
|
|||||||
|
|
||||||
if (message.inGuild()) {
|
if (message.inGuild()) {
|
||||||
expectAssignable<Message<true>>(message);
|
expectAssignable<Message<true>>(message);
|
||||||
const component = await message.awaitMessageComponent({ componentType: 'BUTTON' });
|
const component = await message.awaitMessageComponent({ componentType: 'Button' });
|
||||||
expectType<ButtonInteraction<'cached'>>(component);
|
expectType<ButtonInteraction<'cached'>>(component);
|
||||||
expectType<Message<true>>(await component.reply({ fetchReply: true }));
|
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);
|
expectType<InteractionCollector<ButtonInteraction<'cached'>>>(buttonCollector);
|
||||||
expectAssignable<(test: ButtonInteraction<'cached'>) => boolean | Promise<boolean>>(buttonCollector.filter);
|
expectAssignable<(test: ButtonInteraction<'cached'>) => boolean | Promise<boolean>>(buttonCollector.filter);
|
||||||
expectType<GuildTextBasedChannel>(message.channel);
|
expectType<GuildTextBasedChannel>(message.channel);
|
||||||
@@ -549,15 +549,15 @@ client.on('messageCreate', async message => {
|
|||||||
// Check collector creations.
|
// Check collector creations.
|
||||||
|
|
||||||
// Verify that buttons interactions are inferred.
|
// Verify that buttons interactions are inferred.
|
||||||
const buttonCollector = message.createMessageComponentCollector({ componentType: 'BUTTON' });
|
const buttonCollector = message.createMessageComponentCollector({ componentType: 'Button' });
|
||||||
expectAssignable<Promise<ButtonInteraction>>(message.awaitMessageComponent({ componentType: 'BUTTON' }));
|
expectAssignable<Promise<ButtonInteraction>>(message.awaitMessageComponent({ componentType: 'Button' }));
|
||||||
expectAssignable<Promise<ButtonInteraction>>(channel.awaitMessageComponent({ componentType: 'BUTTON' }));
|
expectAssignable<Promise<ButtonInteraction>>(channel.awaitMessageComponent({ componentType: 'Button' }));
|
||||||
expectAssignable<InteractionCollector<ButtonInteraction>>(buttonCollector);
|
expectAssignable<InteractionCollector<ButtonInteraction>>(buttonCollector);
|
||||||
|
|
||||||
// Verify that select menus interaction are inferred.
|
// Verify that select menus interaction are inferred.
|
||||||
const selectMenuCollector = message.createMessageComponentCollector({ componentType: 'SELECT_MENU' });
|
const selectMenuCollector = message.createMessageComponentCollector({ componentType: 'SelectMenu' });
|
||||||
expectAssignable<Promise<SelectMenuInteraction>>(message.awaitMessageComponent({ componentType: 'SELECT_MENU' }));
|
expectAssignable<Promise<SelectMenuInteraction>>(message.awaitMessageComponent({ componentType: 'SelectMenu' }));
|
||||||
expectAssignable<Promise<SelectMenuInteraction>>(channel.awaitMessageComponent({ componentType: 'SELECT_MENU' }));
|
expectAssignable<Promise<SelectMenuInteraction>>(channel.awaitMessageComponent({ componentType: 'SelectMenu' }));
|
||||||
expectAssignable<InteractionCollector<SelectMenuInteraction>>(selectMenuCollector);
|
expectAssignable<InteractionCollector<SelectMenuInteraction>>(selectMenuCollector);
|
||||||
|
|
||||||
// Verify that message component interactions are default collected types.
|
// Verify that message component interactions are default collected types.
|
||||||
@@ -586,7 +586,7 @@ client.on('messageCreate', async message => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
message.createMessageComponentCollector({
|
message.createMessageComponentCollector({
|
||||||
componentType: 'BUTTON',
|
componentType: 'Button',
|
||||||
filter: i => {
|
filter: i => {
|
||||||
expectType<ButtonInteraction>(i);
|
expectType<ButtonInteraction>(i);
|
||||||
return true;
|
return true;
|
||||||
@@ -594,7 +594,7 @@ client.on('messageCreate', async message => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
message.createMessageComponentCollector({
|
message.createMessageComponentCollector({
|
||||||
componentType: 'SELECT_MENU',
|
componentType: 'SelectMenu',
|
||||||
filter: i => {
|
filter: i => {
|
||||||
expectType<SelectMenuInteraction>(i);
|
expectType<SelectMenuInteraction>(i);
|
||||||
return true;
|
return true;
|
||||||
@@ -609,7 +609,7 @@ client.on('messageCreate', async message => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
message.awaitMessageComponent({
|
message.awaitMessageComponent({
|
||||||
componentType: 'BUTTON',
|
componentType: 'Button',
|
||||||
filter: i => {
|
filter: i => {
|
||||||
expectType<ButtonInteraction>(i);
|
expectType<ButtonInteraction>(i);
|
||||||
return true;
|
return true;
|
||||||
@@ -617,7 +617,7 @@ client.on('messageCreate', async message => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
message.awaitMessageComponent({
|
message.awaitMessageComponent({
|
||||||
componentType: 'SELECT_MENU',
|
componentType: 'SelectMenu',
|
||||||
filter: i => {
|
filter: i => {
|
||||||
expectType<SelectMenuInteraction>(i);
|
expectType<SelectMenuInteraction>(i);
|
||||||
return true;
|
return true;
|
||||||
@@ -645,7 +645,7 @@ client.on('messageCreate', async message => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
channel.awaitMessageComponent({
|
channel.awaitMessageComponent({
|
||||||
componentType: 'BUTTON',
|
componentType: 'Button',
|
||||||
filter: i => {
|
filter: i => {
|
||||||
expectType<ButtonInteraction<'cached'>>(i);
|
expectType<ButtonInteraction<'cached'>>(i);
|
||||||
return true;
|
return true;
|
||||||
@@ -653,7 +653,7 @@ client.on('messageCreate', async message => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
channel.awaitMessageComponent({
|
channel.awaitMessageComponent({
|
||||||
componentType: 'SELECT_MENU',
|
componentType: 'SelectMenu',
|
||||||
filter: i => {
|
filter: i => {
|
||||||
expectType<SelectMenuInteraction<'cached'>>(i);
|
expectType<SelectMenuInteraction<'cached'>>(i);
|
||||||
return true;
|
return true;
|
||||||
@@ -772,8 +772,8 @@ expectType<Message | null>(newsChannel.lastMessage);
|
|||||||
expectType<Message | null>(textChannel.lastMessage);
|
expectType<Message | null>(textChannel.lastMessage);
|
||||||
|
|
||||||
expectDeprecated(storeChannel.clone());
|
expectDeprecated(storeChannel.clone());
|
||||||
expectDeprecated(categoryChannel.createChannel('Store', { type: 'GUILD_STORE' }));
|
expectDeprecated(categoryChannel.createChannel('Store', { type: 'GuildStore' }));
|
||||||
expectDeprecated(guild.channels.create('Store', { type: 'GUILD_STORE' }));
|
expectDeprecated(guild.channels.create('Store', { type: 'GuildStore' }));
|
||||||
|
|
||||||
notPropertyOf(user, 'lastMessage');
|
notPropertyOf(user, 'lastMessage');
|
||||||
notPropertyOf(user, 'lastMessageId');
|
notPropertyOf(user, 'lastMessageId');
|
||||||
@@ -844,9 +844,7 @@ declare const applicationNonChoiceOptionData: ApplicationCommandOptionData & {
|
|||||||
|
|
||||||
declare const applicationSubGroupCommandData: ApplicationCommandSubGroupData;
|
declare const applicationSubGroupCommandData: ApplicationCommandSubGroupData;
|
||||||
{
|
{
|
||||||
expectType<'SUB_COMMAND_GROUP' | ApplicationCommandOptionTypes.SUB_COMMAND_GROUP>(
|
expectType<'SubcommandGroup' | ApplicationCommandOptionType.SubcommandGroup>(applicationSubGroupCommandData.type);
|
||||||
applicationSubGroupCommandData.type,
|
|
||||||
);
|
|
||||||
expectType<ApplicationCommandSubCommandData[] | undefined>(applicationSubGroupCommandData.options);
|
expectType<ApplicationCommandSubCommandData[] | undefined>(applicationSubGroupCommandData.options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -857,25 +855,25 @@ expectType<Promise<ApplicationCommand>>(guildApplicationCommandManager.fetch('0'
|
|||||||
|
|
||||||
declare const categoryChannel: CategoryChannel;
|
declare const categoryChannel: CategoryChannel;
|
||||||
{
|
{
|
||||||
expectType<Promise<VoiceChannel>>(categoryChannel.createChannel('name', { type: 'GUILD_VOICE' }));
|
expectType<Promise<VoiceChannel>>(categoryChannel.createChannel('name', { type: 'GuildVoice' }));
|
||||||
expectType<Promise<TextChannel>>(categoryChannel.createChannel('name', { type: 'GUILD_TEXT' }));
|
expectType<Promise<TextChannel>>(categoryChannel.createChannel('name', { type: 'GuildText' }));
|
||||||
expectType<Promise<NewsChannel>>(categoryChannel.createChannel('name', { type: 'GUILD_NEWS' }));
|
expectType<Promise<NewsChannel>>(categoryChannel.createChannel('name', { type: 'GuildNews' }));
|
||||||
expectType<Promise<StoreChannel>>(categoryChannel.createChannel('name', { type: 'GUILD_STORE' }));
|
expectDeprecated(categoryChannel.createChannel('name', { type: 'GuildStore' }));
|
||||||
expectType<Promise<StageChannel>>(categoryChannel.createChannel('name', { type: 'GUILD_STAGE_VOICE' }));
|
expectType<Promise<StageChannel>>(categoryChannel.createChannel('name', { type: 'GuildStageVoice' }));
|
||||||
expectType<Promise<TextChannel>>(categoryChannel.createChannel('name', {}));
|
expectType<Promise<Exclude<NonThreadGuildBasedChannel, CategoryChannel>>>(categoryChannel.createChannel('name', {}));
|
||||||
expectType<Promise<TextChannel>>(categoryChannel.createChannel('name'));
|
expectType<Promise<Exclude<NonThreadGuildBasedChannel, CategoryChannel>>>(categoryChannel.createChannel('name'));
|
||||||
}
|
}
|
||||||
|
|
||||||
declare const guildChannelManager: GuildChannelManager;
|
declare const guildChannelManager: GuildChannelManager;
|
||||||
{
|
{
|
||||||
type AnyChannel = TextChannel | VoiceChannel | CategoryChannel | NewsChannel | StoreChannel | StageChannel;
|
type AnyChannel = TextChannel | VoiceChannel | CategoryChannel | NewsChannel | StoreChannel | StageChannel;
|
||||||
|
|
||||||
expectType<Promise<VoiceChannel>>(guildChannelManager.create('name', { type: 'GUILD_VOICE' }));
|
expectType<Promise<VoiceChannel>>(guildChannelManager.create('name', { type: 'GuildVoice' }));
|
||||||
expectType<Promise<CategoryChannel>>(guildChannelManager.create('name', { type: 'GUILD_CATEGORY' }));
|
expectType<Promise<CategoryChannel>>(guildChannelManager.create('name', { type: 'GuildCategory' }));
|
||||||
expectType<Promise<TextChannel>>(guildChannelManager.create('name', { type: 'GUILD_TEXT' }));
|
expectType<Promise<TextChannel>>(guildChannelManager.create('name', { type: 'GuildText' }));
|
||||||
expectType<Promise<NewsChannel>>(guildChannelManager.create('name', { type: 'GUILD_NEWS' }));
|
expectType<Promise<NewsChannel>>(guildChannelManager.create('name', { type: 'GuildNews' }));
|
||||||
expectType<Promise<StoreChannel>>(guildChannelManager.create('name', { type: 'GUILD_STORE' }));
|
expectType<Promise<StoreChannel>>(guildChannelManager.create('name', { type: 'GuildStore' }));
|
||||||
expectType<Promise<StageChannel>>(guildChannelManager.create('name', { type: 'GUILD_STAGE_VOICE' }));
|
expectType<Promise<StageChannel>>(guildChannelManager.create('name', { type: 'GuildStageVoice' }));
|
||||||
|
|
||||||
expectType<Promise<Collection<Snowflake, AnyChannel>>>(guildChannelManager.fetch());
|
expectType<Promise<Collection<Snowflake, AnyChannel>>>(guildChannelManager.fetch());
|
||||||
expectType<Promise<Collection<Snowflake, AnyChannel>>>(guildChannelManager.fetch(undefined, {}));
|
expectType<Promise<Collection<Snowflake, AnyChannel>>>(guildChannelManager.fetch(undefined, {}));
|
||||||
@@ -1080,7 +1078,7 @@ client.on('interactionCreate', async interaction => {
|
|||||||
expectType<APIRole>(interaction.options.getRole('test', true));
|
expectType<APIRole>(interaction.options.getRole('test', true));
|
||||||
} else if (interaction.inCachedGuild()) {
|
} else if (interaction.inCachedGuild()) {
|
||||||
const msg = await interaction.reply({ fetchReply: true });
|
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<Message<true>>(msg);
|
||||||
expectType<ButtonInteraction<'cached'>>(btn);
|
expectType<ButtonInteraction<'cached'>>(btn);
|
||||||
@@ -1167,79 +1165,79 @@ collector.on('end', (collection, reason) => {
|
|||||||
expectType<Promise<number | null>>(shard.eval(c => c.readyTimestamp));
|
expectType<Promise<number | null>>(shard.eval(c => c.readyTimestamp));
|
||||||
|
|
||||||
// Test audit logs
|
// 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>>>(
|
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<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>>>(
|
expectAssignable<Promise<GuildAuditLogs<AuditLogEvent.ChannelCreate>>>(
|
||||||
guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.CHANNEL_CREATE }),
|
guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.ChannelCreate }),
|
||||||
);
|
);
|
||||||
expectType<Promise<GuildAuditLogs<AuditLogEvent.ChannelCreate>>>(
|
expectType<Promise<GuildAuditLogs<AuditLogEvent.ChannelCreate>>>(
|
||||||
guild.fetchAuditLogs({ type: 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>>>(
|
expectAssignable<Promise<GuildAuditLogs<AuditLogEvent.IntegrationUpdate>>>(
|
||||||
guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.INTEGRATION_UPDATE }),
|
guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.IntegrationUpdate }),
|
||||||
);
|
);
|
||||||
expectType<Promise<GuildAuditLogs<AuditLogEvent.IntegrationUpdate>>>(
|
expectType<Promise<GuildAuditLogs<AuditLogEvent.IntegrationUpdate>>>(
|
||||||
guild.fetchAuditLogs({ type: AuditLogEvent.IntegrationUpdate }),
|
guild.fetchAuditLogs({ type: AuditLogEvent.IntegrationUpdate }),
|
||||||
);
|
);
|
||||||
|
|
||||||
expectType<Promise<GuildAuditLogs<'ALL'>>>(guild.fetchAuditLogs({ type: 'ALL' }));
|
expectType<Promise<GuildAuditLogs<'All'>>>(guild.fetchAuditLogs({ type: 'All' }));
|
||||||
expectType<Promise<GuildAuditLogs<null>>>(guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.ALL }));
|
expectType<Promise<GuildAuditLogs<null>>>(guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.All }));
|
||||||
expectType<Promise<GuildAuditLogs<'ALL'>>>(guild.fetchAuditLogs());
|
expectType<Promise<GuildAuditLogs<'All'>>>(guild.fetchAuditLogs());
|
||||||
|
|
||||||
expectType<Promise<GuildAuditLogsEntry<'MEMBER_KICK', 'MEMBER_KICK', 'DELETE', 'USER'> | undefined>>(
|
expectType<Promise<GuildAuditLogsEntry<'MemberKick', 'MemberKick', 'Delete', 'User'> | undefined>>(
|
||||||
guild.fetchAuditLogs({ type: 'MEMBER_KICK' }).then(al => al.entries.first()),
|
guild.fetchAuditLogs({ type: 'MemberKick' }).then(al => al.entries.first()),
|
||||||
);
|
);
|
||||||
expectType<Promise<GuildAuditLogsEntry<'MEMBER_KICK', 'MEMBER_KICK', 'DELETE', 'USER'> | undefined>>(
|
expectType<Promise<GuildAuditLogsEntry<'MemberKick', 'MemberKick', 'Delete', 'User'> | undefined>>(
|
||||||
guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.MEMBER_KICK }).then(al => al.entries.first()),
|
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()),
|
guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick }).then(al => al.entries.first()),
|
||||||
);
|
);
|
||||||
|
|
||||||
expectType<Promise<GuildAuditLogsEntry<'ALL', 'ALL', 'ALL', 'UNKNOWN'> | undefined>>(
|
expectType<Promise<GuildAuditLogsEntry<'All', 'All', 'All', 'Unknown'> | undefined>>(
|
||||||
guild.fetchAuditLogs({ type: 'ALL' }).then(al => al.entries.first()),
|
guild.fetchAuditLogs({ type: '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: GuildAuditLogs.Actions.ALL }).then(al => al.entries.first()),
|
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()),
|
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()),
|
guild.fetchAuditLogs().then(al => al.entries.first()),
|
||||||
);
|
);
|
||||||
|
|
||||||
expectType<Promise<null | undefined>>(
|
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>>(
|
expectType<Promise<null | undefined>>(
|
||||||
guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick }).then(al => al.entries.first()?.extra),
|
guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick }).then(al => al.entries.first()?.extra),
|
||||||
);
|
);
|
||||||
expectType<Promise<StageChannel | { id: Snowflake } | undefined>>(
|
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>>(
|
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>>(
|
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>>(
|
expectType<Promise<User | null | undefined>>(
|
||||||
guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick }).then(al => al.entries.first()?.target),
|
guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick }).then(al => al.entries.first()?.target),
|
||||||
);
|
);
|
||||||
expectType<Promise<StageInstance | undefined>>(
|
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>>(
|
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>>(
|
expectType<Promise<User | undefined>>(
|
||||||
@@ -1255,7 +1253,7 @@ declare const NonThreadGuildBasedChannel: NonThreadGuildBasedChannel;
|
|||||||
declare const GuildTextBasedChannel: GuildTextBasedChannel;
|
declare const GuildTextBasedChannel: GuildTextBasedChannel;
|
||||||
|
|
||||||
expectType<DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel>(TextBasedChannel);
|
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,
|
TextBasedChannelTypes,
|
||||||
);
|
);
|
||||||
expectType<StageChannel | VoiceChannel>(VoiceBasedChannel);
|
expectType<StageChannel | VoiceChannel>(VoiceBasedChannel);
|
||||||
|
|||||||
Reference in New Issue
Block a user