mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
fix: use enums from discord-api-types (#7258)
This commit is contained in:
@@ -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,
|
||||
});
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
12
packages/discord.js/typings/index.d.ts
vendored
12
packages/discord.js/typings/index.d.ts
vendored
@@ -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<AllowedThreadType> 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user