seyfert 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/CDN.d.ts +1 -1
- package/lib/api/CDN.js +0 -2
- package/lib/api/Router.js +2 -2
- package/lib/api/Routes/applications.d.ts +29 -33
- package/lib/api/Routes/channels.d.ts +11 -17
- package/lib/api/Routes/interactions.d.ts +3 -7
- package/lib/api/Routes/webhooks.d.ts +4 -6
- package/lib/api/api.d.ts +5 -0
- package/lib/api/api.js +36 -0
- package/lib/api/shared.d.ts +5 -3
- package/lib/builders/Attachment.d.ts +2 -3
- package/lib/builders/Button.d.ts +2 -2
- package/lib/cache/adapters/default.d.ts +1 -0
- package/lib/cache/adapters/default.js +1 -0
- package/lib/cache/adapters/redis.d.ts +1 -0
- package/lib/cache/adapters/redis.js +7 -0
- package/lib/cache/adapters/types.d.ts +1 -0
- package/lib/cache/adapters/workeradapter.d.ts +5 -4
- package/lib/cache/adapters/workeradapter.js +11 -5
- package/lib/cache/index.d.ts +4 -6
- package/lib/cache/index.js +5 -6
- package/lib/cache/resources/default/base.d.ts +2 -1
- package/lib/cache/resources/default/guild-based.d.ts +2 -1
- package/lib/cache/resources/default/guild-based.js +6 -6
- package/lib/cache/resources/default/guild-related.d.ts +2 -1
- package/lib/cache/resources/default/guild-related.js +1 -1
- package/lib/cache/resources/guilds.js +2 -1
- package/lib/cache/resources/overwrites.d.ts +1 -1
- package/lib/cache/resources/overwrites.js +7 -1
- package/lib/client/base.d.ts +18 -171
- package/lib/client/base.js +12 -15
- package/lib/client/client.d.ts +6 -1
- package/lib/client/client.js +13 -12
- package/lib/client/oninteractioncreate.js +4 -4
- package/lib/client/onmessagecreate.js +188 -152
- package/lib/client/workerclient.d.ts +15 -1
- package/lib/client/workerclient.js +135 -27
- package/lib/collection.js +2 -2
- package/lib/commands/applications/chat.d.ts +15 -7
- package/lib/commands/applications/chat.js +7 -7
- package/lib/commands/applications/chatcontext.d.ts +6 -4
- package/lib/commands/applications/chatcontext.js +12 -7
- package/lib/commands/applications/menu.d.ts +5 -1
- package/lib/commands/applications/menu.js +4 -0
- package/lib/commands/applications/menucontext.d.ts +5 -3
- package/lib/commands/applications/menucontext.js +9 -4
- package/lib/commands/applications/options.d.ts +1 -2
- package/lib/commands/decorators.d.ts +17 -5
- package/lib/commands/decorators.js +17 -7
- package/lib/commands/handler.d.ts +5 -5
- package/lib/commands/handler.js +40 -36
- package/lib/commands/optionresolver.d.ts +11 -4
- package/lib/commands/optionresolver.js +6 -4
- package/lib/common/index.d.ts +7 -0
- package/lib/common/index.js +7 -0
- package/lib/common/it/utils.js +2 -0
- package/lib/common/shorters/channels.d.ts +67 -129
- package/lib/common/shorters/channels.js +119 -135
- package/lib/common/shorters/emojis.d.ts +47 -0
- package/lib/common/shorters/emojis.js +80 -0
- package/lib/common/shorters/guilds.d.ts +22 -249
- package/lib/common/shorters/guilds.js +51 -140
- package/lib/common/shorters/members.d.ts +82 -108
- package/lib/common/shorters/members.js +151 -166
- package/lib/common/shorters/messages.d.ts +11 -23
- package/lib/common/shorters/messages.js +58 -104
- package/lib/common/shorters/reactions.d.ts +10 -0
- package/lib/common/shorters/reactions.js +45 -0
- package/lib/common/shorters/roles.d.ts +39 -7
- package/lib/common/shorters/roles.js +74 -42
- package/lib/common/shorters/templates.d.ts +6 -8
- package/lib/common/shorters/templates.js +17 -21
- package/lib/common/shorters/users.d.ts +4 -0
- package/lib/common/shorters/users.js +30 -0
- package/lib/common/shorters/webhook.d.ts +62 -26
- package/lib/common/shorters/webhook.js +113 -58
- package/lib/common/types/options.d.ts +2 -2
- package/lib/common/types/util.d.ts +1 -1
- package/lib/components/handler.d.ts +11 -8
- package/lib/components/handler.js +34 -22
- package/lib/index.d.ts +4 -2
- package/lib/langs/handler.js +7 -2
- package/lib/structures/AutoModerationRule.d.ts +2 -2
- package/lib/structures/ClientUser.d.ts +2 -2
- package/lib/structures/Guild.d.ts +2 -2
- package/lib/structures/GuildEmoji.d.ts +4 -4
- package/lib/structures/GuildEmoji.js +7 -7
- package/lib/structures/GuildMember.d.ts +6 -6
- package/lib/structures/GuildMember.js +2 -2
- package/lib/structures/GuildPreview.d.ts +2 -2
- package/lib/structures/GuildRole.d.ts +2 -2
- package/lib/structures/GuildTemplate.d.ts +2 -2
- package/lib/structures/Interaction.d.ts +7 -8
- package/lib/structures/Interaction.js +1 -1
- package/lib/structures/Message.d.ts +7 -6
- package/lib/structures/Message.js +7 -4
- package/lib/structures/Sticker.d.ts +2 -2
- package/lib/structures/Webhook.d.ts +2 -2
- package/lib/structures/Webhook.js +3 -3
- package/lib/structures/channels.d.ts +19 -20
- package/lib/structures/channels.js +13 -25
- package/lib/structures/extra/Base.d.ts +1 -2
- package/lib/structures/extra/DiscordBase.d.ts +2 -2
- package/lib/websocket/constants/index.js +2 -3
- package/lib/websocket/discord/shard.js +4 -2
- package/lib/websocket/discord/sharder.d.ts +3 -0
- package/lib/websocket/discord/sharder.js +12 -5
- package/lib/websocket/discord/shared.d.ts +3 -0
- package/lib/websocket/discord/worker.d.ts +24 -7
- package/lib/websocket/discord/workermanager.d.ts +30 -6
- package/lib/websocket/discord/workermanager.js +160 -51
- package/package.json +8 -5
|
@@ -3,22 +3,33 @@ import type { CommandOption, OptionsRecord, SubCommand } from './applications/ch
|
|
|
3
3
|
import type { DefaultLocale, MiddlewareContext } from './applications/shared';
|
|
4
4
|
export interface RegisteredMiddlewares {
|
|
5
5
|
}
|
|
6
|
+
export declare enum IntegrationTypes {
|
|
7
|
+
GUILD_INSTALL = 0,
|
|
8
|
+
USER_INSTALL = 1
|
|
9
|
+
}
|
|
10
|
+
export declare enum InteractionContextTypes {
|
|
11
|
+
GUILD = 0,
|
|
12
|
+
BOT_DM = 1,
|
|
13
|
+
PRIVATE_CHANNEL = 2
|
|
14
|
+
}
|
|
6
15
|
type DeclareOptions = {
|
|
7
16
|
name: string;
|
|
8
17
|
description: string;
|
|
9
18
|
botPermissions?: PermissionStrings | bigint;
|
|
10
|
-
|
|
19
|
+
defaultMemberPermissions?: PermissionStrings | bigint;
|
|
11
20
|
guildId?: string[];
|
|
12
|
-
dm?: boolean;
|
|
13
21
|
nsfw?: boolean;
|
|
22
|
+
integrationTypes?: (keyof typeof IntegrationTypes)[];
|
|
23
|
+
contexts?: (keyof typeof InteractionContextTypes)[];
|
|
14
24
|
} | (Omit<{
|
|
15
25
|
name: string;
|
|
16
26
|
description: string;
|
|
17
27
|
botPermissions?: PermissionStrings | bigint;
|
|
18
|
-
|
|
28
|
+
defaultMemberPermissions?: PermissionStrings | bigint;
|
|
19
29
|
guildId?: string[];
|
|
20
|
-
dm?: boolean;
|
|
21
30
|
nsfw?: boolean;
|
|
31
|
+
integrationTypes?: (keyof typeof IntegrationTypes)[];
|
|
32
|
+
contexts?: (keyof typeof InteractionContextTypes)[];
|
|
22
33
|
}, 'type' | 'description'> & {
|
|
23
34
|
type: ApplicationCommandType.User | ApplicationCommandType.Message;
|
|
24
35
|
});
|
|
@@ -96,9 +107,10 @@ export declare function Declare(declare: DeclareOptions): <T extends new (...arg
|
|
|
96
107
|
new (...args: any[]): {
|
|
97
108
|
name: string;
|
|
98
109
|
nsfw: boolean | undefined;
|
|
110
|
+
contexts: InteractionContextTypes[] | undefined;
|
|
111
|
+
integration_types: IntegrationTypes[] | undefined;
|
|
99
112
|
default_member_permissions: string | bigint | undefined;
|
|
100
113
|
botPermissions: bigint | undefined;
|
|
101
|
-
dm?: boolean | undefined;
|
|
102
114
|
description: string;
|
|
103
115
|
type: ApplicationCommandType;
|
|
104
116
|
guild_id?: string[] | undefined;
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Declare = exports.Middlewares = exports.AutoLoad = exports.Options = exports.Group = exports.Groups = exports.GroupsT = exports.LocalesT = exports.Locales = void 0;
|
|
3
|
+
exports.Declare = exports.Middlewares = exports.AutoLoad = exports.Options = exports.Group = exports.Groups = exports.GroupsT = exports.LocalesT = exports.Locales = exports.InteractionContextTypes = exports.IntegrationTypes = void 0;
|
|
4
4
|
const common_1 = require("../common");
|
|
5
|
+
var IntegrationTypes;
|
|
6
|
+
(function (IntegrationTypes) {
|
|
7
|
+
IntegrationTypes[IntegrationTypes["GUILD_INSTALL"] = 0] = "GUILD_INSTALL";
|
|
8
|
+
IntegrationTypes[IntegrationTypes["USER_INSTALL"] = 1] = "USER_INSTALL";
|
|
9
|
+
})(IntegrationTypes || (exports.IntegrationTypes = IntegrationTypes = {}));
|
|
10
|
+
var InteractionContextTypes;
|
|
11
|
+
(function (InteractionContextTypes) {
|
|
12
|
+
InteractionContextTypes[InteractionContextTypes["GUILD"] = 0] = "GUILD";
|
|
13
|
+
InteractionContextTypes[InteractionContextTypes["BOT_DM"] = 1] = "BOT_DM";
|
|
14
|
+
InteractionContextTypes[InteractionContextTypes["PRIVATE_CHANNEL"] = 2] = "PRIVATE_CHANNEL";
|
|
15
|
+
})(InteractionContextTypes || (exports.InteractionContextTypes = InteractionContextTypes = {}));
|
|
5
16
|
function Locales({ name: names, description: descriptions, }) {
|
|
6
17
|
return (target) => class extends target {
|
|
7
18
|
name_localizations = names ? Object.fromEntries(names) : undefined;
|
|
@@ -62,13 +73,14 @@ function Declare(declare) {
|
|
|
62
73
|
return (target) => class extends target {
|
|
63
74
|
name = declare.name;
|
|
64
75
|
nsfw = declare.nsfw;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
76
|
+
contexts = declare.contexts?.map(i => InteractionContextTypes[i]);
|
|
77
|
+
integration_types = declare.integrationTypes?.map(i => IntegrationTypes[i]);
|
|
78
|
+
default_member_permissions = Array.isArray(declare.defaultMemberPermissions)
|
|
79
|
+
? declare.defaultMemberPermissions?.reduce((acc, prev) => acc | common_1.PermissionFlagsBits[prev], BigInt(0)).toString()
|
|
80
|
+
: declare.defaultMemberPermissions;
|
|
68
81
|
botPermissions = Array.isArray(declare.botPermissions)
|
|
69
82
|
? declare.botPermissions?.reduce((acc, prev) => acc | common_1.PermissionFlagsBits[prev], BigInt(0))
|
|
70
83
|
: declare.botPermissions;
|
|
71
|
-
dm;
|
|
72
84
|
description = '';
|
|
73
85
|
type = common_1.ApplicationCommandType.ChatInput;
|
|
74
86
|
guild_id;
|
|
@@ -78,8 +90,6 @@ function Declare(declare) {
|
|
|
78
90
|
this.description = declare.description;
|
|
79
91
|
if ('type' in declare)
|
|
80
92
|
this.type = declare.type;
|
|
81
|
-
if ('dm' in declare)
|
|
82
|
-
this.dm = !!declare.dm;
|
|
83
93
|
if ('guildId' in declare)
|
|
84
94
|
this.guild_id = declare.guildId;
|
|
85
95
|
// check if all properties are valid
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { BaseClient } from '../client/base';
|
|
2
1
|
import type { Logger } from '../common';
|
|
3
2
|
import { BaseHandler } from '../common';
|
|
4
3
|
import { Command } from './applications/chat';
|
|
5
4
|
import { ContextMenuCommand } from './applications/menu';
|
|
5
|
+
import type { UsingClient } from './applications/shared';
|
|
6
6
|
export declare class CommandHandler extends BaseHandler {
|
|
7
7
|
protected logger: Logger;
|
|
8
|
-
protected client:
|
|
8
|
+
protected client: UsingClient;
|
|
9
9
|
values: (Command | ContextMenuCommand)[];
|
|
10
10
|
protected filter: (path: string) => boolean;
|
|
11
|
-
constructor(logger: Logger, client:
|
|
11
|
+
constructor(logger: Logger, client: UsingClient);
|
|
12
12
|
reload(resolve: string | Command): Promise<void>;
|
|
13
13
|
reloadAll(stopIfFail?: boolean): Promise<void>;
|
|
14
|
-
load(commandsDir: string, client:
|
|
15
|
-
private
|
|
14
|
+
load(commandsDir: string, client: UsingClient): Promise<(Command | ContextMenuCommand)[]>;
|
|
15
|
+
private __parseCommandLocales;
|
|
16
16
|
}
|
package/lib/commands/handler.js
CHANGED
|
@@ -63,6 +63,7 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
63
63
|
commandInstance.__filePath = command.path;
|
|
64
64
|
commandInstance.options ??= [];
|
|
65
65
|
if (commandInstance.__d) {
|
|
66
|
+
//@AutoLoad
|
|
66
67
|
const options = await this.getFiles((0, node_path_1.dirname)(command.path));
|
|
67
68
|
for (const option of options) {
|
|
68
69
|
if (command.name === (0, node_path_1.basename)(option)) {
|
|
@@ -95,45 +96,60 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
this.values.push(commandInstance);
|
|
98
|
-
this.
|
|
99
|
+
this.__parseCommandLocales(commandInstance, client);
|
|
99
100
|
for (const i of commandInstance.options ?? []) {
|
|
100
101
|
if (i instanceof chat_1.SubCommand) {
|
|
101
|
-
this.
|
|
102
|
+
this.__parseCommandLocales(i, client);
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
return this.values;
|
|
106
107
|
}
|
|
107
|
-
|
|
108
|
+
__parseCommandLocales(command, client) {
|
|
108
109
|
if (command.__t) {
|
|
109
110
|
command.name_localizations = {};
|
|
110
111
|
command.description_localizations = {};
|
|
111
112
|
for (const locale of Object.keys(client.langs.values)) {
|
|
112
|
-
const
|
|
113
|
-
if (Object.values(common_1.Locale).includes(locale))
|
|
114
|
-
|
|
113
|
+
const locales = this.client.langs.aliases.find(x => x[0] === locale)?.[1] ?? [];
|
|
114
|
+
if (Object.values(common_1.Locale).includes(locale))
|
|
115
|
+
locales.push(locale);
|
|
116
|
+
if (command.__t.name) {
|
|
117
|
+
for (const i of locales) {
|
|
115
118
|
const valueName = client.langs.getKey(locale, command.__t.name);
|
|
116
119
|
if (valueName)
|
|
117
|
-
command.name_localizations[
|
|
120
|
+
command.name_localizations[i] = valueName;
|
|
118
121
|
}
|
|
119
|
-
|
|
122
|
+
}
|
|
123
|
+
if (command.__t.description) {
|
|
124
|
+
for (const i of locales) {
|
|
120
125
|
const valueKey = client.langs.getKey(locale, command.__t.description);
|
|
121
126
|
if (valueKey)
|
|
122
|
-
command.description_localizations[
|
|
127
|
+
command.description_localizations[i] = valueKey;
|
|
123
128
|
}
|
|
124
129
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
for (const options of command.options ?? []) {
|
|
133
|
+
if (options instanceof chat_1.SubCommand || !options.locales)
|
|
134
|
+
continue;
|
|
135
|
+
options.name_localizations = {};
|
|
136
|
+
options.description_localizations = {};
|
|
137
|
+
for (const locale of Object.keys(client.langs.values)) {
|
|
138
|
+
const locales = this.client.langs.aliases.find(x => x[0] === locale)?.[1] ?? [];
|
|
139
|
+
if (Object.values(common_1.Locale).includes(locale))
|
|
140
|
+
locales.push(locale);
|
|
141
|
+
if (options.locales.name) {
|
|
142
|
+
for (const i of locales) {
|
|
143
|
+
const valueName = client.langs.getKey(locale, options.locales.name);
|
|
128
144
|
if (valueName)
|
|
129
|
-
|
|
145
|
+
options.name_localizations[i] = valueName;
|
|
130
146
|
}
|
|
131
147
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const valueKey = client.langs.getKey(locale,
|
|
148
|
+
if (options.locales.description) {
|
|
149
|
+
for (const i of locales) {
|
|
150
|
+
const valueKey = client.langs.getKey(locale, options.locales.description);
|
|
135
151
|
if (valueKey)
|
|
136
|
-
|
|
152
|
+
options.description_localizations[i] = valueKey;
|
|
137
153
|
}
|
|
138
154
|
}
|
|
139
155
|
}
|
|
@@ -141,37 +157,25 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
141
157
|
if (command instanceof chat_1.Command && command.__tGroups) {
|
|
142
158
|
command.groups = {};
|
|
143
159
|
for (const locale of Object.keys(client.langs.values)) {
|
|
144
|
-
const
|
|
160
|
+
const locales = this.client.langs.aliases.find(x => x[0] === locale)?.[1] ?? [];
|
|
161
|
+
if (Object.values(common_1.Locale).includes(locale))
|
|
162
|
+
locales.push(locale);
|
|
145
163
|
for (const group in command.__tGroups) {
|
|
146
164
|
command.groups[group] ??= {
|
|
147
165
|
defaultDescription: command.__tGroups[group].defaultDescription,
|
|
148
166
|
description: [],
|
|
149
167
|
name: [],
|
|
150
168
|
};
|
|
151
|
-
if (
|
|
152
|
-
|
|
153
|
-
const valueName = client.langs.getKey(locale, command.__tGroups[group].name);
|
|
154
|
-
if (valueName) {
|
|
155
|
-
command.groups[group].name.push([locale, valueName]);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
if (command.__tGroups[group].description) {
|
|
159
|
-
const valueKey = client.langs.getKey(locale, command.__tGroups[group].description);
|
|
160
|
-
if (valueKey) {
|
|
161
|
-
command.groups[group].description.push([locale, valueKey]);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
for (const i of aliases) {
|
|
166
|
-
if (command.__tGroups[group].name) {
|
|
169
|
+
if (command.__tGroups[group].name) {
|
|
170
|
+
for (const i of locales) {
|
|
167
171
|
const valueName = client.langs.getKey(locale, command.__tGroups[group].name);
|
|
168
172
|
if (valueName) {
|
|
169
173
|
command.groups[group].name.push([i, valueName]);
|
|
170
174
|
}
|
|
171
175
|
}
|
|
172
176
|
}
|
|
173
|
-
|
|
174
|
-
|
|
177
|
+
if (command.__tGroups[group].description) {
|
|
178
|
+
for (const i of locales) {
|
|
175
179
|
const valueKey = client.langs.getKey(locale, command.__tGroups[group].description);
|
|
176
180
|
if (valueKey) {
|
|
177
181
|
command.groups[group].description.push([i, valueKey]);
|
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
import { Attachment, GuildMember } from '..';
|
|
2
|
-
import type { APIApplicationCommandInteractionDataOption,
|
|
2
|
+
import type { APIApplicationCommandInteractionDataOption, APIAttachment, APIGuildMember, APIInteractionDataResolvedChannel, APIInteractionGuildMember, APIRole, APIUser, MakeRequired } from '../common';
|
|
3
3
|
import { ApplicationCommandOptionType } from '../common';
|
|
4
4
|
import type { AllChannels } from '../structures';
|
|
5
5
|
import { GuildRole, InteractionGuildMember, User } from '../structures';
|
|
6
6
|
import type { Command, CommandAutocompleteOption, SubCommand } from './applications/chat';
|
|
7
7
|
import type { UsingClient } from './applications/shared';
|
|
8
|
+
export type ContextOptionsResolved = {
|
|
9
|
+
members?: Record<string, APIGuildMember | APIInteractionGuildMember | GuildMember | InteractionGuildMember>;
|
|
10
|
+
users?: Record<string, APIUser | User>;
|
|
11
|
+
roles?: Record<string, APIRole | GuildRole>;
|
|
12
|
+
channels?: Record<string, APIInteractionDataResolvedChannel | AllChannels>;
|
|
13
|
+
attachments?: Record<string, APIAttachment | Attachment>;
|
|
14
|
+
};
|
|
8
15
|
export declare class OptionResolver {
|
|
9
16
|
private client;
|
|
10
17
|
parent?: Command | undefined;
|
|
11
18
|
guildId?: string | undefined;
|
|
12
|
-
resolved?:
|
|
19
|
+
resolved?: ContextOptionsResolved | undefined;
|
|
13
20
|
readonly options: OptionResolved[];
|
|
14
21
|
hoistedOptions: OptionResolved[];
|
|
15
22
|
private subCommand;
|
|
16
23
|
private group;
|
|
17
|
-
constructor(client: UsingClient, options: APIApplicationCommandInteractionDataOption[], parent?: Command | undefined, guildId?: string | undefined, resolved?:
|
|
24
|
+
constructor(client: UsingClient, options: APIApplicationCommandInteractionDataOption[], parent?: Command | undefined, guildId?: string | undefined, resolved?: ContextOptionsResolved | undefined);
|
|
18
25
|
get fullCommandName(): string;
|
|
19
26
|
getCommand(): Command | SubCommand | undefined;
|
|
20
27
|
getAutocompleteValue(): string | undefined;
|
|
@@ -28,7 +35,7 @@ export declare class OptionResolver {
|
|
|
28
35
|
private getTypedOption;
|
|
29
36
|
getChannel(name: string, required?: true): AllChannels;
|
|
30
37
|
getString(name: string, required?: true): string;
|
|
31
|
-
transformOption(option: APIApplicationCommandInteractionDataOption, resolved?:
|
|
38
|
+
transformOption(option: APIApplicationCommandInteractionDataOption, resolved?: ContextOptionsResolved): OptionResolved;
|
|
32
39
|
}
|
|
33
40
|
export interface OptionResolved {
|
|
34
41
|
name: string;
|
|
@@ -122,14 +122,16 @@ class OptionResolver {
|
|
|
122
122
|
const value = resolve.value;
|
|
123
123
|
const user = resolved.users?.[value];
|
|
124
124
|
if (user) {
|
|
125
|
-
resolve.user = new structures_1.User(this.client, user);
|
|
125
|
+
resolve.user = user instanceof structures_1.User ? user : new structures_1.User(this.client, user);
|
|
126
126
|
}
|
|
127
127
|
const member = resolved.members?.[value];
|
|
128
128
|
if (member) {
|
|
129
129
|
resolve.member =
|
|
130
|
-
member instanceof __1.GuildMember
|
|
130
|
+
member instanceof __1.GuildMember || member instanceof structures_1.InteractionGuildMember
|
|
131
131
|
? member
|
|
132
|
-
:
|
|
132
|
+
: 'permissions' in member
|
|
133
|
+
? new structures_1.InteractionGuildMember(this.client, member, user, this.guildId)
|
|
134
|
+
: new __1.GuildMember(this.client, member, user, this.guildId);
|
|
133
135
|
}
|
|
134
136
|
const channel = resolved.channels?.[value];
|
|
135
137
|
if (channel) {
|
|
@@ -141,7 +143,7 @@ class OptionResolver {
|
|
|
141
143
|
}
|
|
142
144
|
const attachment = resolved.attachments?.[value];
|
|
143
145
|
if (attachment) {
|
|
144
|
-
resolve.attachment = new __1.Attachment(this.client, attachment);
|
|
146
|
+
resolve.attachment = attachment instanceof __1.Attachment ? attachment : new __1.Attachment(this.client, attachment);
|
|
145
147
|
}
|
|
146
148
|
}
|
|
147
149
|
return resolve;
|
package/lib/common/index.d.ts
CHANGED
|
@@ -4,8 +4,15 @@ export * from 'discord-api-types/v10';
|
|
|
4
4
|
export * from './it/colors';
|
|
5
5
|
export * from './it/logger';
|
|
6
6
|
export * from './shorters/channels';
|
|
7
|
+
export * from './shorters/emojis';
|
|
7
8
|
export * from './shorters/guilds';
|
|
9
|
+
export * from './shorters/members';
|
|
10
|
+
export * from './shorters/messages';
|
|
11
|
+
export * from './shorters/reactions';
|
|
12
|
+
export * from './shorters/roles';
|
|
13
|
+
export * from './shorters/templates';
|
|
8
14
|
export * from './shorters/users';
|
|
15
|
+
export * from './shorters/webhook';
|
|
9
16
|
export * from './types/options';
|
|
10
17
|
export * from './types/resolvables';
|
|
11
18
|
export * from './types/util';
|
package/lib/common/index.js
CHANGED
|
@@ -21,8 +21,15 @@ __exportStar(require("discord-api-types/v10"), exports);
|
|
|
21
21
|
__exportStar(require("./it/colors"), exports);
|
|
22
22
|
__exportStar(require("./it/logger"), exports);
|
|
23
23
|
__exportStar(require("./shorters/channels"), exports);
|
|
24
|
+
__exportStar(require("./shorters/emojis"), exports);
|
|
24
25
|
__exportStar(require("./shorters/guilds"), exports);
|
|
26
|
+
__exportStar(require("./shorters/members"), exports);
|
|
27
|
+
__exportStar(require("./shorters/messages"), exports);
|
|
28
|
+
__exportStar(require("./shorters/reactions"), exports);
|
|
29
|
+
__exportStar(require("./shorters/roles"), exports);
|
|
30
|
+
__exportStar(require("./shorters/templates"), exports);
|
|
25
31
|
__exportStar(require("./shorters/users"), exports);
|
|
32
|
+
__exportStar(require("./shorters/webhook"), exports);
|
|
26
33
|
__exportStar(require("./types/options"), exports);
|
|
27
34
|
__exportStar(require("./types/resolvables"), exports);
|
|
28
35
|
__exportStar(require("./types/util"), exports);
|
package/lib/common/it/utils.js
CHANGED
|
@@ -240,6 +240,7 @@ async function magicImport(path) {
|
|
|
240
240
|
return require(path);
|
|
241
241
|
}
|
|
242
242
|
catch {
|
|
243
|
+
// biome-ignore lint/security/noGlobalEval: modules import broke
|
|
243
244
|
return eval('((path) => import(`file:///${path}`))')(path.split('\\').join('\\\\'));
|
|
244
245
|
}
|
|
245
246
|
}
|
|
@@ -248,6 +249,7 @@ function fakePromise(value) {
|
|
|
248
249
|
if (value instanceof Promise)
|
|
249
250
|
return value;
|
|
250
251
|
return {
|
|
252
|
+
// biome-ignore lint/suspicious/noThenProperty: magic
|
|
251
253
|
then: callback => callback(value),
|
|
252
254
|
};
|
|
253
255
|
}
|
|
@@ -4,135 +4,73 @@ import { type AllChannels } from '../../structures/channels';
|
|
|
4
4
|
import { PermissionsBitField } from '../../structures/extra/Permissions';
|
|
5
5
|
import { BaseShorter } from './base';
|
|
6
6
|
export declare class ChannelShorter extends BaseShorter {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
id: string;
|
|
75
|
-
deny: PermissionsBitField;
|
|
76
|
-
allow: PermissionsBitField;
|
|
77
|
-
}[];
|
|
78
|
-
member: {
|
|
79
|
-
type: number;
|
|
80
|
-
id: string;
|
|
81
|
-
deny: PermissionsBitField;
|
|
82
|
-
allow: PermissionsBitField;
|
|
83
|
-
} | undefined;
|
|
84
|
-
}>;
|
|
85
|
-
rolePermissions: (channelId: string, role: GuildRole, checkAdmin?: boolean) => Promise<PermissionsBitField>;
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
get pins(): {
|
|
89
|
-
/**
|
|
90
|
-
* Fetches pinned messages in the channel.
|
|
91
|
-
* @param channelId The ID of the channel.
|
|
92
|
-
* @returns A Promise that resolves to an array of pinned messages.
|
|
93
|
-
*/
|
|
94
|
-
fetch: (channelId: string) => Promise<Message[]>;
|
|
95
|
-
/**
|
|
96
|
-
* Pins a message in the channel.
|
|
97
|
-
* @param messageId The ID of the message to pin.
|
|
98
|
-
* @param channelId The ID of the channel.
|
|
99
|
-
* @param reason The reason for pinning the message.
|
|
100
|
-
* @returns A Promise that resolves when the message is successfully pinned.
|
|
101
|
-
*/
|
|
102
|
-
set: (messageId: string, channelId: string, reason?: string) => Promise<never>;
|
|
103
|
-
/**
|
|
104
|
-
* Unpins a message in the channel.
|
|
105
|
-
* @param messageId The ID of the message to unpin.
|
|
106
|
-
* @param channelId The ID of the channel.
|
|
107
|
-
* @param reason The reason for unpinning the message.
|
|
108
|
-
* @returns A Promise that resolves when the message is successfully unpinned.
|
|
109
|
-
*/
|
|
110
|
-
delete: (messageId: string, channelId: string, reason?: string) => Promise<never>;
|
|
111
|
-
};
|
|
112
|
-
get overwrites(): {
|
|
113
|
-
memberPermissions: (channelId: string, member: GuildMember, checkAdmin?: boolean) => Promise<PermissionsBitField>;
|
|
114
|
-
overwritesFor: (channelId: string, member: GuildMember) => Promise<{
|
|
115
|
-
everyone: {
|
|
116
|
-
type: number;
|
|
117
|
-
id: string;
|
|
118
|
-
deny: PermissionsBitField;
|
|
119
|
-
allow: PermissionsBitField;
|
|
120
|
-
} | undefined;
|
|
121
|
-
roles: {
|
|
122
|
-
type: number;
|
|
123
|
-
id: string;
|
|
124
|
-
deny: PermissionsBitField;
|
|
125
|
-
allow: PermissionsBitField;
|
|
126
|
-
}[];
|
|
127
|
-
member: {
|
|
128
|
-
type: number;
|
|
129
|
-
id: string;
|
|
130
|
-
deny: PermissionsBitField;
|
|
131
|
-
allow: PermissionsBitField;
|
|
132
|
-
} | undefined;
|
|
133
|
-
}>;
|
|
134
|
-
rolePermissions: (channelId: string, role: GuildRole, checkAdmin?: boolean) => Promise<PermissionsBitField>;
|
|
135
|
-
};
|
|
7
|
+
/**
|
|
8
|
+
* Fetches a channel by its ID.
|
|
9
|
+
* @param id The ID of the channel to fetch.
|
|
10
|
+
* @param force Whether to force fetching the channel from the API even if it exists in the cache.
|
|
11
|
+
* @returns A Promise that resolves to the fetched channel.
|
|
12
|
+
*/
|
|
13
|
+
fetch(id: string, force?: boolean): Promise<AllChannels>;
|
|
14
|
+
/**
|
|
15
|
+
* Deletes a channel by its ID.
|
|
16
|
+
* @param id The ID of the channel to delete.
|
|
17
|
+
* @param optional Optional parameters for the deletion.
|
|
18
|
+
* @returns A Promise that resolves to the deleted channel.
|
|
19
|
+
*/
|
|
20
|
+
delete(id: string, optional?: ChannelShorterOptionalParams): Promise<AllChannels>;
|
|
21
|
+
/**
|
|
22
|
+
* Edits a channel by its ID.
|
|
23
|
+
* @param id The ID of the channel to edit.
|
|
24
|
+
* @param body The updated channel data.
|
|
25
|
+
* @param optional Optional parameters for the editing.
|
|
26
|
+
* @returns A Promise that resolves to the edited channel.
|
|
27
|
+
*/
|
|
28
|
+
edit(id: string, body: RESTPatchAPIChannelJSONBody, optional?: ChannelShorterOptionalParams): Promise<AllChannels>;
|
|
29
|
+
/**
|
|
30
|
+
* Sends a typing indicator to the channel.
|
|
31
|
+
* @param id The ID of the channel.
|
|
32
|
+
* @returns A Promise that resolves when the typing indicator is successfully sent.
|
|
33
|
+
*/
|
|
34
|
+
typing(id: string): Promise<void>;
|
|
35
|
+
pins(channelId: string): Promise<Message[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Pins a message in the channel.
|
|
38
|
+
* @param messageId The ID of the message to pin.
|
|
39
|
+
* @param channelId The ID of the channel.
|
|
40
|
+
* @param reason The reason for pinning the message.
|
|
41
|
+
* @returns A Promise that resolves when the message is successfully pinned.
|
|
42
|
+
*/
|
|
43
|
+
setPin(messageId: string, channelId: string, reason?: string): Promise<never>;
|
|
44
|
+
/**
|
|
45
|
+
* Unpins a message in the channel.
|
|
46
|
+
* @param messageId The ID of the message to unpin.
|
|
47
|
+
* @param channelId The ID of the channel.
|
|
48
|
+
* @param reason The reason for unpinning the message.
|
|
49
|
+
* @returns A Promise that resolves when the message is successfully unpinned.
|
|
50
|
+
*/
|
|
51
|
+
deletePin(messageId: string, channelId: string, reason?: string): Promise<never>;
|
|
52
|
+
memberPermissions(channelId: string, member: GuildMember, checkAdmin?: boolean): Promise<PermissionsBitField>;
|
|
53
|
+
overwritesFor(channelId: string, member: GuildMember): Promise<{
|
|
54
|
+
everyone: {
|
|
55
|
+
type: number;
|
|
56
|
+
id: string;
|
|
57
|
+
deny: PermissionsBitField;
|
|
58
|
+
allow: PermissionsBitField;
|
|
59
|
+
} | undefined;
|
|
60
|
+
roles: {
|
|
61
|
+
type: number;
|
|
62
|
+
id: string;
|
|
63
|
+
deny: PermissionsBitField;
|
|
64
|
+
allow: PermissionsBitField;
|
|
65
|
+
}[];
|
|
66
|
+
member: {
|
|
67
|
+
type: number;
|
|
68
|
+
id: string;
|
|
69
|
+
deny: PermissionsBitField;
|
|
70
|
+
allow: PermissionsBitField;
|
|
71
|
+
} | undefined;
|
|
72
|
+
}>;
|
|
73
|
+
rolePermissions(channelId: string, role: GuildRole, checkAdmin?: boolean): Promise<PermissionsBitField>;
|
|
136
74
|
}
|
|
137
75
|
export type ChannelShorterOptionalParams = Partial<{
|
|
138
76
|
guildId: string;
|