mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 12:33:30 +01:00
fix: use enums from discord-api-types (#7258)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
|
const { InviteTargetType } = require('discord-api-types/v9');
|
||||||
const CachedManager = require('./CachedManager');
|
const CachedManager = require('./CachedManager');
|
||||||
const { Error } = require('../errors');
|
const { Error } = require('../errors');
|
||||||
const Invite = require('../structures/Invite');
|
const Invite = require('../structures/Invite');
|
||||||
@@ -190,7 +191,7 @@ class GuildInviteManager extends CachedManager {
|
|||||||
unique,
|
unique,
|
||||||
target_user_id: this.client.users.resolveId(targetUser),
|
target_user_id: this.client.users.resolveId(targetUser),
|
||||||
target_application_id: targetApplication?.id ?? targetApplication?.applicationId ?? targetApplication,
|
target_application_id: targetApplication?.id ?? targetApplication?.applicationId ?? targetApplication,
|
||||||
target_type: targetType,
|
target_type: InviteTargetType[targetType],
|
||||||
},
|
},
|
||||||
reason,
|
reason,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -187,10 +187,10 @@ class BaseGuildTextChannel extends GuildChannel {
|
|||||||
* @property {number} [maxUses=0] Maximum number of uses
|
* @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 {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,
|
* @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,
|
* @property {ApplicationResolvable} [targetApplication] The embedded application to open for this invite,
|
||||||
* required if `targetType` is 2, the application must have the `EMBEDDED` flag
|
* required if `targetType` is `EMBEDDED_APPLICATION`, the application must have the `EMBEDDED` flag
|
||||||
* @property {TargetType} [targetType] The type of the target for this voice channel invite
|
* @property {InviteTargetType} [targetType] The type of the target for this voice channel invite
|
||||||
* @property {string} [reason] The reason for creating the invite
|
* @property {string} [reason] The reason for creating the invite
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
const { ApplicationCommandType } = require('discord-api-types/v9');
|
const { ApplicationCommandOptionType } = 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');
|
||||||
@@ -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: ApplicationCommandType[option.type],
|
type: ApplicationCommandOptionType[option.type],
|
||||||
};
|
};
|
||||||
|
|
||||||
if ('value' in option) result.value = option.value;
|
if ('value' in option) result.value = option.value;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { ApplicationCommandType } = require('discord-api-types/v9');
|
const { ApplicationCommandType, ApplicationCommandOptionType } = require('discord-api-types/v9');
|
||||||
const CommandInteraction = require('./CommandInteraction');
|
const CommandInteraction = require('./CommandInteraction');
|
||||||
const CommandInteractionOptionResolver = require('./CommandInteractionOptionResolver');
|
const CommandInteractionOptionResolver = require('./CommandInteractionOptionResolver');
|
||||||
|
|
||||||
@@ -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: 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) {
|
if ('premium_tier' in data) {
|
||||||
/**
|
/**
|
||||||
* The premium tier of this guild
|
* The premium tier of this guild
|
||||||
* @type {PremiumTier}
|
* @type {GuildPremiumTier}
|
||||||
*/
|
*/
|
||||||
this.premiumTier = GuildPremiumTier[data.premium_tier];
|
this.premiumTier = GuildPremiumTier[data.premium_tier];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { InviteTargetType } = require('discord-api-types/v9');
|
||||||
const Base = require('./Base');
|
const Base = require('./Base');
|
||||||
const { GuildScheduledEvent } = require('./GuildScheduledEvent');
|
const { GuildScheduledEvent } = require('./GuildScheduledEvent');
|
||||||
const IntegrationApplication = require('./IntegrationApplication');
|
const IntegrationApplication = require('./IntegrationApplication');
|
||||||
@@ -151,20 +152,12 @@ class Invite extends Base {
|
|||||||
this.targetApplication ??= null;
|
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) {
|
if ('target_type' in data) {
|
||||||
/**
|
/**
|
||||||
* The target type
|
* The target type
|
||||||
* @type {?TargetType}
|
* @type {?InviteTargetType}
|
||||||
*/
|
*/
|
||||||
this.targetType = data.target_type;
|
this.targetType = InviteTargetType[data.target_type];
|
||||||
} else {
|
} else {
|
||||||
this.targetType ??= null;
|
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 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 {
|
export interface APIRequest {
|
||||||
method: 'get' | 'post' | 'delete' | 'patch' | 'put';
|
method: 'get' | 'post' | 'delete' | 'patch' | 'put';
|
||||||
@@ -4214,7 +4218,7 @@ interface GuildAuditLogsTypes {
|
|||||||
ChannelDelete: ['Channel', 'Delete'];
|
ChannelDelete: ['Channel', 'Delete'];
|
||||||
ChannelOverwriteCreate: ['Channel', 'Create'];
|
ChannelOverwriteCreate: ['Channel', 'Create'];
|
||||||
ChannelOverwriteUpdate: ['Channel', 'Update'];
|
ChannelOverwriteUpdate: ['Channel', 'Update'];
|
||||||
ChannelOverwriteDelete: ['CHANNEL', 'Delete'];
|
ChannelOverwriteDelete: ['Channel', 'Delete'];
|
||||||
MemberKick: ['User', 'Delete'];
|
MemberKick: ['User', 'Delete'];
|
||||||
MemberPrune: ['User', 'Delete'];
|
MemberPrune: ['User', 'Delete'];
|
||||||
MemberBanAdd: ['User', 'Delete'];
|
MemberBanAdd: ['User', 'Delete'];
|
||||||
@@ -5345,7 +5349,7 @@ export type ThreadChannelTypeKey = 'GuildNewsThread' | 'GuildPublicThread' | 'Gu
|
|||||||
export interface ThreadCreateOptions<AllowedThreadType> extends StartThreadOptions {
|
export interface ThreadCreateOptions<AllowedThreadType> extends StartThreadOptions {
|
||||||
startMessage?: MessageResolvable;
|
startMessage?: MessageResolvable;
|
||||||
type?: AllowedThreadType;
|
type?: AllowedThreadType;
|
||||||
invitable?: AllowedThreadType extends 'GUILD_PRIVATE_THREAD' | 12 ? boolean : never;
|
invitable?: AllowedThreadType extends 'GUILD_PRIVATE_THREAD' | ChannelType.GuildPrivateThread ? boolean : never;
|
||||||
rateLimitPerUser?: number;
|
rateLimitPerUser?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user