seyfert 1.0.1 → 1.1.1
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/builders/Attachment.d.ts +2 -3
- package/lib/cache/adapters/redis.js +6 -0
- package/lib/cache/adapters/types.d.ts +23 -23
- package/lib/cache/adapters/workeradapter.d.ts +4 -4
- package/lib/cache/adapters/workeradapter.js +10 -5
- package/lib/cache/index.d.ts +4 -5
- package/lib/cache/index.js +4 -3
- package/lib/cache/resources/default/base.d.ts +11 -10
- package/lib/cache/resources/default/guild-based.d.ts +8 -7
- package/lib/cache/resources/default/guild-based.js +8 -7
- package/lib/cache/resources/default/guild-related.d.ts +10 -9
- package/lib/cache/resources/default/guild-related.js +3 -2
- 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 +33 -179
- package/lib/client/base.js +56 -21
- package/lib/client/client.d.ts +10 -3
- package/lib/client/client.js +23 -8
- package/lib/client/oninteractioncreate.js +9 -9
- package/lib/client/onmessagecreate.js +192 -153
- package/lib/client/workerclient.d.ts +9 -3
- package/lib/client/workerclient.js +50 -23
- package/lib/collection.js +2 -2
- package/lib/commands/applications/chat.d.ts +16 -8
- package/lib/commands/applications/chat.js +20 -13
- package/lib/commands/applications/chatcontext.d.ts +6 -4
- package/lib/commands/applications/chatcontext.js +6 -1
- package/lib/commands/applications/menu.d.ts +5 -1
- package/lib/commands/applications/menu.js +11 -5
- package/lib/commands/applications/menucontext.d.ts +5 -3
- package/lib/commands/applications/menucontext.js +7 -2
- package/lib/commands/applications/options.d.ts +1 -2
- package/lib/commands/applications/shared.d.ts +5 -4
- package/lib/commands/decorators.d.ts +18 -6
- package/lib/commands/decorators.js +18 -8
- package/lib/commands/handler.d.ts +11 -5
- package/lib/commands/handler.js +46 -37
- 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.d.ts +1 -0
- package/lib/common/it/utils.js +4 -1
- 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 -6
- package/lib/common/shorters/users.js +29 -33
- 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 +3 -0
- package/lib/components/handler.d.ts +28 -9
- package/lib/components/handler.js +28 -11
- package/lib/events/handler.d.ts +10 -2
- package/lib/events/handler.js +6 -8
- package/lib/index.d.ts +4 -2
- package/lib/index.js +1 -1
- package/lib/langs/handler.d.ts +8 -0
- package/lib/langs/handler.js +8 -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 +7 -6
- package/lib/structures/GuildMember.js +5 -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 +9 -10
- package/lib/structures/Interaction.js +2 -2
- package/lib/structures/Message.d.ts +8 -7
- package/lib/structures/Message.js +7 -4
- package/lib/structures/Sticker.d.ts +2 -2
- package/lib/structures/User.d.ts +1 -0
- package/lib/structures/User.js +5 -0
- package/lib/structures/Webhook.d.ts +2 -2
- package/lib/structures/Webhook.js +3 -3
- package/lib/structures/channels.d.ts +21 -22
- 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 +1 -0
- 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 +1 -0
- package/lib/websocket/discord/worker.d.ts +2 -1
- package/lib/websocket/discord/workermanager.d.ts +8 -3
- package/lib/websocket/discord/workermanager.js +78 -30
- package/package.json +8 -6
|
@@ -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
|
});
|
|
@@ -81,7 +92,7 @@ export declare function Options(options: (new () => SubCommand)[] | OptionsRecor
|
|
|
81
92
|
} & T;
|
|
82
93
|
export declare function AutoLoad(): <T extends new (...args: any[]) => {}>(target: T) => {
|
|
83
94
|
new (...args: any[]): {
|
|
84
|
-
|
|
95
|
+
__autoload: boolean;
|
|
85
96
|
};
|
|
86
97
|
} & T;
|
|
87
98
|
export type ParseMiddlewares<T extends Record<string, MiddlewareContext>> = {
|
|
@@ -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;
|
|
@@ -48,7 +59,7 @@ function Options(options) {
|
|
|
48
59
|
exports.Options = Options;
|
|
49
60
|
function AutoLoad() {
|
|
50
61
|
return (target) => class extends target {
|
|
51
|
-
|
|
62
|
+
__autoload = true;
|
|
52
63
|
};
|
|
53
64
|
}
|
|
54
65
|
exports.AutoLoad = AutoLoad;
|
|
@@ -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,22 @@
|
|
|
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
|
+
export interface CommandHandlerLike {
|
|
7
|
+
values: CommandHandler['values'];
|
|
8
|
+
load: CommandHandler['load'];
|
|
9
|
+
reload: CommandHandler['reload'];
|
|
10
|
+
reloadAll: CommandHandler['reloadAll'];
|
|
11
|
+
}
|
|
6
12
|
export declare class CommandHandler extends BaseHandler {
|
|
7
13
|
protected logger: Logger;
|
|
8
|
-
protected client:
|
|
14
|
+
protected client: UsingClient;
|
|
9
15
|
values: (Command | ContextMenuCommand)[];
|
|
10
16
|
protected filter: (path: string) => boolean;
|
|
11
|
-
constructor(logger: Logger, client:
|
|
17
|
+
constructor(logger: Logger, client: UsingClient);
|
|
12
18
|
reload(resolve: string | Command): Promise<void>;
|
|
13
19
|
reloadAll(stopIfFail?: boolean): Promise<void>;
|
|
14
|
-
load(commandsDir: string, client:
|
|
15
|
-
private
|
|
20
|
+
load(commandsDir: string, client: UsingClient): Promise<(Command | ContextMenuCommand)[]>;
|
|
21
|
+
private __parseCommandLocales;
|
|
16
22
|
}
|
package/lib/commands/handler.js
CHANGED
|
@@ -39,6 +39,7 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
39
39
|
for (const command of result) {
|
|
40
40
|
let commandInstance;
|
|
41
41
|
try {
|
|
42
|
+
//@ts-expect-error abstract class
|
|
42
43
|
commandInstance = new command.file();
|
|
43
44
|
}
|
|
44
45
|
catch (e) {
|
|
@@ -55,6 +56,7 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
55
56
|
if (commandInstance instanceof menu_1.ContextMenuCommand) {
|
|
56
57
|
this.values.push(commandInstance);
|
|
57
58
|
commandInstance.__filePath = command.path;
|
|
59
|
+
await this.__callback?.(commandInstance);
|
|
58
60
|
continue;
|
|
59
61
|
}
|
|
60
62
|
if (!(commandInstance instanceof chat_1.Command)) {
|
|
@@ -62,15 +64,18 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
62
64
|
}
|
|
63
65
|
commandInstance.__filePath = command.path;
|
|
64
66
|
commandInstance.options ??= [];
|
|
65
|
-
if (commandInstance.
|
|
67
|
+
if (commandInstance.__autoload) {
|
|
68
|
+
//@AutoLoad
|
|
66
69
|
const options = await this.getFiles((0, node_path_1.dirname)(command.path));
|
|
67
70
|
for (const option of options) {
|
|
68
71
|
if (command.name === (0, node_path_1.basename)(option)) {
|
|
69
72
|
continue;
|
|
70
73
|
}
|
|
71
74
|
try {
|
|
75
|
+
//@ts-expect-error abstract class
|
|
72
76
|
const subCommand = new (result.find(x => x.path === option).file)();
|
|
73
77
|
if (subCommand instanceof chat_1.SubCommand) {
|
|
78
|
+
subCommand.__filePath = option;
|
|
74
79
|
commandInstance.options.push(subCommand);
|
|
75
80
|
}
|
|
76
81
|
}
|
|
@@ -95,45 +100,61 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
95
100
|
}
|
|
96
101
|
}
|
|
97
102
|
this.values.push(commandInstance);
|
|
98
|
-
this.
|
|
103
|
+
this.__parseCommandLocales(commandInstance, client);
|
|
99
104
|
for (const i of commandInstance.options ?? []) {
|
|
100
105
|
if (i instanceof chat_1.SubCommand) {
|
|
101
|
-
this.
|
|
106
|
+
this.__parseCommandLocales(i, client);
|
|
102
107
|
}
|
|
103
108
|
}
|
|
109
|
+
await this.__callback?.(commandInstance);
|
|
104
110
|
}
|
|
105
111
|
return this.values;
|
|
106
112
|
}
|
|
107
|
-
|
|
113
|
+
__parseCommandLocales(command, client) {
|
|
108
114
|
if (command.__t) {
|
|
109
115
|
command.name_localizations = {};
|
|
110
116
|
command.description_localizations = {};
|
|
111
117
|
for (const locale of Object.keys(client.langs.values)) {
|
|
112
|
-
const
|
|
113
|
-
if (Object.values(common_1.Locale).includes(locale))
|
|
114
|
-
|
|
118
|
+
const locales = this.client.langs.aliases.find(x => x[0] === locale)?.[1] ?? [];
|
|
119
|
+
if (Object.values(common_1.Locale).includes(locale))
|
|
120
|
+
locales.push(locale);
|
|
121
|
+
if (command.__t.name) {
|
|
122
|
+
for (const i of locales) {
|
|
115
123
|
const valueName = client.langs.getKey(locale, command.__t.name);
|
|
116
124
|
if (valueName)
|
|
117
|
-
command.name_localizations[
|
|
125
|
+
command.name_localizations[i] = valueName;
|
|
118
126
|
}
|
|
119
|
-
|
|
127
|
+
}
|
|
128
|
+
if (command.__t.description) {
|
|
129
|
+
for (const i of locales) {
|
|
120
130
|
const valueKey = client.langs.getKey(locale, command.__t.description);
|
|
121
131
|
if (valueKey)
|
|
122
|
-
command.description_localizations[
|
|
132
|
+
command.description_localizations[i] = valueKey;
|
|
123
133
|
}
|
|
124
134
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
for (const options of command.options ?? []) {
|
|
138
|
+
if (options instanceof chat_1.SubCommand || !options.locales)
|
|
139
|
+
continue;
|
|
140
|
+
options.name_localizations = {};
|
|
141
|
+
options.description_localizations = {};
|
|
142
|
+
for (const locale of Object.keys(client.langs.values)) {
|
|
143
|
+
const locales = this.client.langs.aliases.find(x => x[0] === locale)?.[1] ?? [];
|
|
144
|
+
if (Object.values(common_1.Locale).includes(locale))
|
|
145
|
+
locales.push(locale);
|
|
146
|
+
if (options.locales.name) {
|
|
147
|
+
for (const i of locales) {
|
|
148
|
+
const valueName = client.langs.getKey(locale, options.locales.name);
|
|
128
149
|
if (valueName)
|
|
129
|
-
|
|
150
|
+
options.name_localizations[i] = valueName;
|
|
130
151
|
}
|
|
131
152
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const valueKey = client.langs.getKey(locale,
|
|
153
|
+
if (options.locales.description) {
|
|
154
|
+
for (const i of locales) {
|
|
155
|
+
const valueKey = client.langs.getKey(locale, options.locales.description);
|
|
135
156
|
if (valueKey)
|
|
136
|
-
|
|
157
|
+
options.description_localizations[i] = valueKey;
|
|
137
158
|
}
|
|
138
159
|
}
|
|
139
160
|
}
|
|
@@ -141,37 +162,25 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
141
162
|
if (command instanceof chat_1.Command && command.__tGroups) {
|
|
142
163
|
command.groups = {};
|
|
143
164
|
for (const locale of Object.keys(client.langs.values)) {
|
|
144
|
-
const
|
|
165
|
+
const locales = this.client.langs.aliases.find(x => x[0] === locale)?.[1] ?? [];
|
|
166
|
+
if (Object.values(common_1.Locale).includes(locale))
|
|
167
|
+
locales.push(locale);
|
|
145
168
|
for (const group in command.__tGroups) {
|
|
146
169
|
command.groups[group] ??= {
|
|
147
170
|
defaultDescription: command.__tGroups[group].defaultDescription,
|
|
148
171
|
description: [],
|
|
149
172
|
name: [],
|
|
150
173
|
};
|
|
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) {
|
|
174
|
+
if (command.__tGroups[group].name) {
|
|
175
|
+
for (const i of locales) {
|
|
167
176
|
const valueName = client.langs.getKey(locale, command.__tGroups[group].name);
|
|
168
177
|
if (valueName) {
|
|
169
178
|
command.groups[group].name.push([i, valueName]);
|
|
170
179
|
}
|
|
171
180
|
}
|
|
172
181
|
}
|
|
173
|
-
|
|
174
|
-
|
|
182
|
+
if (command.__tGroups[group].description) {
|
|
183
|
+
for (const i of locales) {
|
|
175
184
|
const valueKey = client.langs.getKey(locale, command.__tGroups[group].description);
|
|
176
185
|
if (valueKey) {
|
|
177
186
|
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.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export declare function filterSplit<Element, Predicate extends (value: Element)
|
|
|
40
40
|
*/
|
|
41
41
|
export declare class BaseHandler {
|
|
42
42
|
protected logger: Logger;
|
|
43
|
+
__callback?: (...args: any[]) => any;
|
|
43
44
|
/**
|
|
44
45
|
* Initializes a new instance of the BaseHandler class.
|
|
45
46
|
* @param logger The logger instance.
|
package/lib/common/it/utils.js
CHANGED
|
@@ -95,6 +95,7 @@ exports.filterSplit = filterSplit;
|
|
|
95
95
|
*/
|
|
96
96
|
class BaseHandler {
|
|
97
97
|
logger;
|
|
98
|
+
__callback;
|
|
98
99
|
/**
|
|
99
100
|
* Initializes a new instance of the BaseHandler class.
|
|
100
101
|
* @param logger The logger instance.
|
|
@@ -240,7 +241,8 @@ async function magicImport(path) {
|
|
|
240
241
|
return require(path);
|
|
241
242
|
}
|
|
242
243
|
catch {
|
|
243
|
-
|
|
244
|
+
// biome-ignore lint/security/noGlobalEval: modules import broke
|
|
245
|
+
return eval('((path) => import(`file:///${path}?update=${Date.now()}`))')(path.split('\\').join('\\\\'));
|
|
244
246
|
}
|
|
245
247
|
}
|
|
246
248
|
exports.magicImport = magicImport;
|
|
@@ -248,6 +250,7 @@ function fakePromise(value) {
|
|
|
248
250
|
if (value instanceof Promise)
|
|
249
251
|
return value;
|
|
250
252
|
return {
|
|
253
|
+
// biome-ignore lint/suspicious/noThenProperty: magic
|
|
251
254
|
then: callback => callback(value),
|
|
252
255
|
};
|
|
253
256
|
}
|
|
@@ -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;
|