From e7b880697314d79d2edc004e825911e2d5934b39 Mon Sep 17 00:00:00 2001 From: MARCROCK22 <57925328+MARCROCK22@users.noreply.github.com> Date: Fri, 1 Nov 2024 21:13:10 -0400 Subject: [PATCH] fix: permissions and magicImport (#285) * fix: magicImport * fix: dapi-types * fix: socram --- src/common/it/utils.ts | 11 ++++++----- src/types/payloads/_interactions/base.ts | 2 +- src/types/payloads/application.ts | 2 +- src/types/rest/guild.ts | 2 +- src/types/rest/oauth2.ts | 2 +- src/types/rest/user.ts | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/common/it/utils.ts b/src/common/it/utils.ts index 43a9f2b..9700270 100644 --- a/src/common/it/utils.ts +++ b/src/common/it/utils.ts @@ -279,11 +279,12 @@ export const ReplaceRegex = { }; export async function magicImport(path: string) { - try { - return require(path); - } catch { - return eval('((path) => import(`file:///${path}?update=${Date.now()}`))')(path.split('\\').join('\\\\')); - } + //@ts-expect-error + if (typeof require === 'undefined' || globalThis.Deno) + return new Function('return ((path) => import(`file:///${path}?update=${Date.now()}`))')()( + path.split('\\').join('\\\\'), + ); + return require(path); } export type OnFailCallback = (error: unknown) => any; diff --git a/src/types/payloads/_interactions/base.ts b/src/types/payloads/_interactions/base.ts index 16f14b7..810cb09 100644 --- a/src/types/payloads/_interactions/base.ts +++ b/src/types/payloads/_interactions/base.ts @@ -1,5 +1,5 @@ import type { ApplicationIntegrationType, InteractionContextType } from '..'; -import type { ChannelType, Snowflake } from '../..'; +import type { ChannelType, Permissions, Snowflake } from '../..'; import type { LocaleString } from '../../rest'; import type { diff --git a/src/types/payloads/application.ts b/src/types/payloads/application.ts index a10303a..c53f5f7 100644 --- a/src/types/payloads/application.ts +++ b/src/types/payloads/application.ts @@ -3,7 +3,7 @@ */ import type { LocalizationMap } from '.'; -import type { Snowflake } from '..'; +import type { Permissions, Snowflake } from '..'; import type { APIPartialGuild } from './guild'; import type { ApplicationIntegrationType } from './interactions'; import type { OAuth2Scopes } from './oauth2'; diff --git a/src/types/rest/guild.ts b/src/types/rest/guild.ts index 2056727..9b1b968 100644 --- a/src/types/rest/guild.ts +++ b/src/types/rest/guild.ts @@ -1,4 +1,4 @@ -import type { Snowflake } from '..'; +import type { Permissions, Snowflake } from '..'; import type { APIBan, APIChannel, diff --git a/src/types/rest/oauth2.ts b/src/types/rest/oauth2.ts index 8b55937..3379ee4 100644 --- a/src/types/rest/oauth2.ts +++ b/src/types/rest/oauth2.ts @@ -1,4 +1,4 @@ -import type { Snowflake } from '..'; +import type { Permissions, Snowflake } from '..'; import type { APIApplication, APIGuild, APIUser, APIWebhook, OAuth2Scopes } from '../payloads'; /** diff --git a/src/types/rest/user.ts b/src/types/rest/user.ts index fd9aa92..1ec8906 100644 --- a/src/types/rest/user.ts +++ b/src/types/rest/user.ts @@ -1,4 +1,4 @@ -import type { Snowflake } from '..'; +import type { Permissions, Snowflake } from '..'; import type { APIApplicationRoleConnection, APIChannel,