diff --git a/packages/discord.js/src/managers/GuildInviteManager.js b/packages/discord.js/src/managers/GuildInviteManager.js index c229a5810..a2ef60d1a 100644 --- a/packages/discord.js/src/managers/GuildInviteManager.js +++ b/packages/discord.js/src/managers/GuildInviteManager.js @@ -1,6 +1,7 @@ 'use strict'; const { Collection } = require('@discordjs/collection'); +const { InviteTargetType } = require('discord-api-types/v9'); const CachedManager = require('./CachedManager'); const { Error } = require('../errors'); const Invite = require('../structures/Invite'); @@ -190,7 +191,7 @@ class GuildInviteManager extends CachedManager { unique, target_user_id: this.client.users.resolveId(targetUser), target_application_id: targetApplication?.id ?? targetApplication?.applicationId ?? targetApplication, - target_type: targetType, + target_type: InviteTargetType[targetType], }, reason, }); diff --git a/packages/discord.js/src/structures/BaseGuildTextChannel.js b/packages/discord.js/src/structures/BaseGuildTextChannel.js index efa139d9c..ac25c10ef 100644 --- a/packages/discord.js/src/structures/BaseGuildTextChannel.js +++ b/packages/discord.js/src/structures/BaseGuildTextChannel.js @@ -187,10 +187,10 @@ class BaseGuildTextChannel extends GuildChannel { * @property {number} [maxUses=0] Maximum number of uses * @property {boolean} [unique=false] Create a unique invite, or use an existing one with similar settings * @property {UserResolvable} [targetUser] The user whose stream to display for this invite, - * required if `targetType` is 1, the user must be streaming in the channel + * required if `targetType` is `STREAM`, the user must be streaming in the channel * @property {ApplicationResolvable} [targetApplication] The embedded application to open for this invite, - * required if `targetType` is 2, the application must have the `EMBEDDED` flag - * @property {TargetType} [targetType] The type of the target for this voice channel invite + * required if `targetType` is `EMBEDDED_APPLICATION`, the application must have the `EMBEDDED` flag + * @property {InviteTargetType} [targetType] The type of the target for this voice channel invite * @property {string} [reason] The reason for creating the invite */ diff --git a/packages/discord.js/src/structures/CommandInteraction.js b/packages/discord.js/src/structures/CommandInteraction.js index 5052ba195..09baaf3b9 100644 --- a/packages/discord.js/src/structures/CommandInteraction.js +++ b/packages/discord.js/src/structures/CommandInteraction.js @@ -1,7 +1,7 @@ 'use strict'; const { Collection } = require('@discordjs/collection'); -const { ApplicationCommandType } = require('discord-api-types/v9'); +const { ApplicationCommandOptionType } = require('discord-api-types/v9'); const Interaction = require('./Interaction'); const InteractionWebhook = require('./InteractionWebhook'); const InteractionResponses = require('./interfaces/InteractionResponses'); @@ -151,7 +151,7 @@ class CommandInteraction extends Interaction { transformOption(option, resolved) { const result = { name: option.name, - type: ApplicationCommandType[option.type], + type: ApplicationCommandOptionType[option.type], }; if ('value' in option) result.value = option.value; diff --git a/packages/discord.js/src/structures/ContextMenuCommandInteraction.js b/packages/discord.js/src/structures/ContextMenuCommandInteraction.js index da2fa80f5..318233efa 100644 --- a/packages/discord.js/src/structures/ContextMenuCommandInteraction.js +++ b/packages/discord.js/src/structures/ContextMenuCommandInteraction.js @@ -1,6 +1,6 @@ 'use strict'; -const { ApplicationCommandType } = require('discord-api-types/v9'); +const { ApplicationCommandType, ApplicationCommandOptionType } = require('discord-api-types/v9'); const CommandInteraction = require('./CommandInteraction'); const CommandInteractionOptionResolver = require('./CommandInteractionOptionResolver'); @@ -45,7 +45,7 @@ class ContextMenuCommandInteraction extends CommandInteraction { if (resolved.users?.[target_id]) { result.push( - this.transformOption({ name: 'user', type: ApplicationCommandType.User, value: target_id }, resolved), + this.transformOption({ name: 'user', type: ApplicationCommandOptionType.User, value: target_id }, resolved), ); } diff --git a/packages/discord.js/src/structures/Guild.js b/packages/discord.js/src/structures/Guild.js index 2d942f562..cfa0e845b 100644 --- a/packages/discord.js/src/structures/Guild.js +++ b/packages/discord.js/src/structures/Guild.js @@ -238,7 +238,7 @@ class Guild extends AnonymousGuild { if ('premium_tier' in data) { /** * The premium tier of this guild - * @type {PremiumTier} + * @type {GuildPremiumTier} */ this.premiumTier = GuildPremiumTier[data.premium_tier]; } diff --git a/packages/discord.js/src/structures/Invite.js b/packages/discord.js/src/structures/Invite.js index 17ee9da0a..9fa3e432f 100644 --- a/packages/discord.js/src/structures/Invite.js +++ b/packages/discord.js/src/structures/Invite.js @@ -1,5 +1,6 @@ 'use strict'; +const { InviteTargetType } = require('discord-api-types/v9'); const Base = require('./Base'); const { GuildScheduledEvent } = require('./GuildScheduledEvent'); const IntegrationApplication = require('./IntegrationApplication'); @@ -151,20 +152,12 @@ class Invite extends Base { this.targetApplication ??= null; } - /** - * The type of the invite target: - * * 1: STREAM - * * 2: EMBEDDED_APPLICATION - * @typedef {number} TargetType - * @see {@link https://discord.com/developers/docs/resources/invite#invite-object-invite-target-types} - */ - if ('target_type' in data) { /** * The target type - * @type {?TargetType} + * @type {?InviteTargetType} */ - this.targetType = data.target_type; + this.targetType = InviteTargetType[data.target_type]; } else { this.targetType ??= null; } diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 33e116431..2af371602 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -3323,9 +3323,13 @@ export type AllowedImageSize = 16 | 32 | 56 | 64 | 96 | 128 | 256 | 300 | 512 | export type AllowedPartial = User | Channel | GuildMember | Message | MessageReaction; -export type AllowedThreadTypeForNewsChannel = 'GUILD_NEWS_THREAD' | 10; +export type AllowedThreadTypeForNewsChannel = 'GUILD_NEWS_THREAD' | ChannelType.GuildNewsThread; -export type AllowedThreadTypeForTextChannel = 'GUILD_PUBLIC_THREAD' | 'GUILD_PRIVATE_THREAD' | 11 | 12; +export type AllowedThreadTypeForTextChannel = + | 'GUILD_PUBLIC_THREAD' + | 'GUILD_PRIVATE_THREAD' + | ChannelType.GuildPublicThread + | ChannelType.GuildPrivateThread; export interface APIRequest { method: 'get' | 'post' | 'delete' | 'patch' | 'put'; @@ -4214,7 +4218,7 @@ interface GuildAuditLogsTypes { ChannelDelete: ['Channel', 'Delete']; ChannelOverwriteCreate: ['Channel', 'Create']; ChannelOverwriteUpdate: ['Channel', 'Update']; - ChannelOverwriteDelete: ['CHANNEL', 'Delete']; + ChannelOverwriteDelete: ['Channel', 'Delete']; MemberKick: ['User', 'Delete']; MemberPrune: ['User', 'Delete']; MemberBanAdd: ['User', 'Delete']; @@ -5345,7 +5349,7 @@ export type ThreadChannelTypeKey = 'GuildNewsThread' | 'GuildPublicThread' | 'Gu export interface ThreadCreateOptions extends StartThreadOptions { startMessage?: MessageResolvable; type?: AllowedThreadType; - invitable?: AllowedThreadType extends 'GUILD_PRIVATE_THREAD' | 12 ? boolean : never; + invitable?: AllowedThreadType extends 'GUILD_PRIVATE_THREAD' | ChannelType.GuildPrivateThread ? boolean : never; rateLimitPerUser?: number; }