seyfert 2.1.1-dev-11537652481.0 → 2.1.1-dev-11635725680.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/client/base.js +6 -3
- package/lib/commands/handle.d.ts +1 -0
- package/lib/commands/handle.js +13 -14
- package/lib/common/it/formatter.d.ts +28 -0
- package/lib/common/it/formatter.js +21 -0
- package/lib/structures/Interaction.d.ts +1 -1
- package/lib/structures/Interaction.js +1 -3
- package/package.json +1 -1
package/lib/client/base.js
CHANGED
|
@@ -299,10 +299,13 @@ class BaseClient {
|
|
|
299
299
|
};
|
|
300
300
|
for (const i in locations) {
|
|
301
301
|
const key = i;
|
|
302
|
-
const location = locations[
|
|
303
|
-
if (
|
|
302
|
+
const location = locations[key];
|
|
303
|
+
if (key in locationsFullPaths)
|
|
304
304
|
continue;
|
|
305
|
-
|
|
305
|
+
if (typeof location === 'string')
|
|
306
|
+
locationsFullPaths[key] = (0, node_path_1.join)(process.cwd(), locations.output, location);
|
|
307
|
+
else
|
|
308
|
+
locationsFullPaths[key] = location;
|
|
306
309
|
}
|
|
307
310
|
const obj = {
|
|
308
311
|
debug: !!debug,
|
package/lib/commands/handle.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export declare class HandleCommand {
|
|
|
16
16
|
client: UsingClient;
|
|
17
17
|
constructor(client: UsingClient);
|
|
18
18
|
autocomplete(interaction: AutocompleteInteraction, optionsResolver: OptionResolverStructure, command?: CommandAutocompleteOption): Promise<void>;
|
|
19
|
+
contextMenu(command: ContextMenuCommand, interaction: MessageCommandInteraction | UserCommandInteraction, context: MenuCommandContext<MessageCommandInteraction | UserCommandInteraction>): Promise<any>;
|
|
19
20
|
contextMenuMessage(command: ContextMenuCommand, interaction: MessageCommandInteraction, context: MenuCommandContext<MessageCommandInteraction>): Promise<any>;
|
|
20
21
|
contextMenuUser(command: ContextMenuCommand, interaction: UserCommandInteraction, context: MenuCommandContext<UserCommandInteraction>): Promise<any>;
|
|
21
22
|
entryPoint(command: EntryPointCommand, interaction: EntryPointInteraction, context: EntryPointContext): Promise<any>;
|
package/lib/commands/handle.js
CHANGED
|
@@ -36,12 +36,8 @@ class HandleCommand {
|
|
|
36
36
|
// pass
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
async
|
|
40
|
-
|
|
41
|
-
return this.contextMenuUser(command, interaction, context);
|
|
42
|
-
}
|
|
43
|
-
async contextMenuUser(command, interaction, context) {
|
|
44
|
-
if (context.guildId && command.botPermissions && interaction.appPermissions) {
|
|
39
|
+
async contextMenu(command, interaction, context) {
|
|
40
|
+
if (context.guildId && command.botPermissions) {
|
|
45
41
|
const permissions = this.checkPermissions(interaction.appPermissions, command.botPermissions);
|
|
46
42
|
if (permissions)
|
|
47
43
|
return command.onBotPermissionsFail(context, permissions);
|
|
@@ -71,8 +67,14 @@ class HandleCommand {
|
|
|
71
67
|
}
|
|
72
68
|
}
|
|
73
69
|
}
|
|
70
|
+
contextMenuMessage(command, interaction, context) {
|
|
71
|
+
return this.contextMenu(command, interaction, context);
|
|
72
|
+
}
|
|
73
|
+
contextMenuUser(command, interaction, context) {
|
|
74
|
+
return this.contextMenu(command, interaction, context);
|
|
75
|
+
}
|
|
74
76
|
async entryPoint(command, interaction, context) {
|
|
75
|
-
if (context.guildId && command.botPermissions
|
|
77
|
+
if (context.guildId && command.botPermissions) {
|
|
76
78
|
const permissions = this.checkPermissions(interaction.appPermissions, command.botPermissions);
|
|
77
79
|
if (permissions)
|
|
78
80
|
return command.onBotPermissionsFail(context, permissions);
|
|
@@ -103,7 +105,7 @@ class HandleCommand {
|
|
|
103
105
|
}
|
|
104
106
|
}
|
|
105
107
|
async chatInput(command, interaction, resolver, context) {
|
|
106
|
-
if (context.guildId
|
|
108
|
+
if (context.guildId) {
|
|
107
109
|
if (command.botPermissions) {
|
|
108
110
|
const permissions = this.checkPermissions(interaction.appPermissions, command.botPermissions);
|
|
109
111
|
if (permissions)
|
|
@@ -172,17 +174,14 @@ class HandleCommand {
|
|
|
172
174
|
const data = this.makeMenuCommand(body, shardId, __reply);
|
|
173
175
|
if (!data)
|
|
174
176
|
return;
|
|
175
|
-
this.contextMenuMessage(data.command,
|
|
176
|
-
// @ts-expect-error
|
|
177
|
-
data.interaction, data.context);
|
|
177
|
+
await this.contextMenuMessage(data.command, data.interaction, data.context);
|
|
178
178
|
break;
|
|
179
179
|
}
|
|
180
180
|
case types_1.ApplicationCommandType.User: {
|
|
181
181
|
const data = this.makeMenuCommand(body, shardId, __reply);
|
|
182
182
|
if (!data)
|
|
183
183
|
return;
|
|
184
|
-
|
|
185
|
-
this.contextMenuUser(data.command, data.interaction, data.context);
|
|
184
|
+
await this.contextMenuUser(data.command, data.interaction, data.context);
|
|
186
185
|
break;
|
|
187
186
|
}
|
|
188
187
|
case types_1.ApplicationCommandType.PrimaryEntryPoint: {
|
|
@@ -199,10 +198,10 @@ class HandleCommand {
|
|
|
199
198
|
case types_1.ApplicationCommandType.ChatInput: {
|
|
200
199
|
const parentCommand = this.getCommand(body.data);
|
|
201
200
|
const optionsResolver = this.makeResolver(this.client, body.data.options ?? [], parentCommand, body.guild_id, body.data.resolved);
|
|
202
|
-
const interaction = structures_1.BaseInteraction.from(this.client, body, __reply);
|
|
203
201
|
const command = optionsResolver.getCommand();
|
|
204
202
|
if (!command?.run)
|
|
205
203
|
return this.client.logger.warn(`${optionsResolver.fullCommandName} command does not have 'run' callback`);
|
|
204
|
+
const interaction = structures_1.BaseInteraction.from(this.client, body, __reply);
|
|
206
205
|
const context = new _1.CommandContext(this.client, interaction, optionsResolver, shardId, command);
|
|
207
206
|
const extendContext = this.client.options?.context?.(interaction) ?? {};
|
|
208
207
|
Object.assign(context, extendContext);
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
import type { BitFieldResolvable } from '../../structures/extra/BitField';
|
|
2
|
+
import type { OAuth2Scopes, PermissionFlagsBits } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Represents options for creating a OAuth2 uri
|
|
5
|
+
*/
|
|
6
|
+
export type OAuth2URLOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* Oauth2 scopes to be used.
|
|
9
|
+
*/
|
|
10
|
+
scopes: OAuth2Scopes[];
|
|
11
|
+
/**
|
|
12
|
+
* Permissions to be granted to the application.
|
|
13
|
+
*/
|
|
14
|
+
permissions: BitFieldResolvable<typeof PermissionFlagsBits>;
|
|
15
|
+
/**
|
|
16
|
+
* Whether guild select must be disabled in oauth2 interface.
|
|
17
|
+
*/
|
|
18
|
+
disableGuildSelect?: boolean;
|
|
19
|
+
};
|
|
1
20
|
/**
|
|
2
21
|
* Represents heading levels.
|
|
3
22
|
*/
|
|
@@ -183,5 +202,14 @@ export declare const Formatter: {
|
|
|
183
202
|
* @returns The formatted channel link.
|
|
184
203
|
*/
|
|
185
204
|
channelLink(channelId: string, guildId?: string): string;
|
|
205
|
+
/**
|
|
206
|
+
* Forms a oauth2 invite link for the bot.
|
|
207
|
+
* @param applicationId The ID of the application.
|
|
208
|
+
* @param options Options for forming the invite link.
|
|
209
|
+
* @param options.scopes Oauth2 scopes to be used.
|
|
210
|
+
* @param options.disableGuildSelect Whether or not guild select must be disabled in oauth2 interface.
|
|
211
|
+
* @param options.permissions Permissions to be granted to the application.
|
|
212
|
+
*/
|
|
213
|
+
generateOAuth2URL(applicationId: string, { scopes, permissions, disableGuildSelect }: OAuth2URLOptions): string;
|
|
186
214
|
};
|
|
187
215
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Formatter = exports.TimestampStyle = exports.HeadingLevel = void 0;
|
|
4
|
+
const Permissions_1 = require("../../structures/extra/Permissions");
|
|
4
5
|
/**
|
|
5
6
|
* Represents heading levels.
|
|
6
7
|
*/
|
|
@@ -222,4 +223,24 @@ exports.Formatter = {
|
|
|
222
223
|
channelLink(channelId, guildId) {
|
|
223
224
|
return `https://discord.com/channels/${guildId ?? '@me'}/${channelId}`;
|
|
224
225
|
},
|
|
226
|
+
/**
|
|
227
|
+
* Forms a oauth2 invite link for the bot.
|
|
228
|
+
* @param applicationId The ID of the application.
|
|
229
|
+
* @param options Options for forming the invite link.
|
|
230
|
+
* @param options.scopes Oauth2 scopes to be used.
|
|
231
|
+
* @param options.disableGuildSelect Whether or not guild select must be disabled in oauth2 interface.
|
|
232
|
+
* @param options.permissions Permissions to be granted to the application.
|
|
233
|
+
*/
|
|
234
|
+
generateOAuth2URL(applicationId, { scopes, permissions, disableGuildSelect = false }) {
|
|
235
|
+
const queryOptions = new URLSearchParams({
|
|
236
|
+
client_id: applicationId,
|
|
237
|
+
scope: scopes.join(' '),
|
|
238
|
+
disable_guild_select: String(disableGuildSelect),
|
|
239
|
+
});
|
|
240
|
+
if (permissions) {
|
|
241
|
+
permissions = Permissions_1.PermissionsBitField.resolve(permissions);
|
|
242
|
+
queryOptions.set('permissions', permissions.toString());
|
|
243
|
+
}
|
|
244
|
+
return `https://discord.com/oauth2/authorize?${queryOptions.toString()}`;
|
|
245
|
+
},
|
|
225
246
|
};
|
|
@@ -29,7 +29,7 @@ export declare class BaseInteraction<FromGuild extends boolean = boolean, Type e
|
|
|
29
29
|
channel?: AllChannels;
|
|
30
30
|
message?: MessageStructure;
|
|
31
31
|
replied?: Promise<boolean | RESTPostAPIInteractionCallbackResult | undefined> | boolean;
|
|
32
|
-
appPermissions
|
|
32
|
+
appPermissions: PermissionsBitField;
|
|
33
33
|
entitlements: EntitlementStructure[];
|
|
34
34
|
constructor(client: UsingClient, interaction: Type, __reply?: __InternalReplyFunction | undefined);
|
|
35
35
|
static transformBodyRequest(body: ReplyInteractionBody, files: RawFile[] | undefined, self: UsingClient): APIInteractionResponse;
|
|
@@ -35,9 +35,7 @@ class BaseInteraction extends DiscordBase_1.DiscordBase {
|
|
|
35
35
|
if (interaction.message) {
|
|
36
36
|
this.message = transformers_1.Transformers.Message(client, interaction.message);
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
this.appPermissions = new Permissions_1.PermissionsBitField(Number(interaction.app_permissions));
|
|
40
|
-
}
|
|
38
|
+
this.appPermissions = new Permissions_1.PermissionsBitField(Number(interaction.app_permissions));
|
|
41
39
|
if (interaction.channel) {
|
|
42
40
|
this.channel = (0, _1.channelFrom)(interaction.channel, client);
|
|
43
41
|
}
|