seyfert 0.1.0 → 1.0.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/README.md +19 -30
- package/lib/api/CDN.d.ts +0 -8
- package/lib/api/CDN.js +7 -13
- package/lib/api/Router.d.ts +2 -2
- package/lib/api/Router.js +1 -1
- package/lib/api/Routes/applications.d.ts +1 -1
- package/lib/api/Routes/channels.d.ts +1 -1
- package/lib/api/Routes/gateway.d.ts +1 -1
- package/lib/api/Routes/guilds.d.ts +1 -1
- package/lib/api/Routes/interactions.d.ts +1 -1
- package/lib/api/Routes/invites.d.ts +1 -1
- package/lib/api/Routes/stage-instances.d.ts +1 -1
- package/lib/api/Routes/stickers.d.ts +1 -1
- package/lib/api/Routes/users.d.ts +1 -1
- package/lib/api/Routes/voice.d.ts +1 -1
- package/lib/api/Routes/webhooks.d.ts +1 -1
- package/lib/api/api.d.ts +44 -0
- package/lib/api/api.js +354 -0
- package/lib/api/bucket.d.ts +19 -0
- package/lib/api/bucket.js +71 -0
- package/lib/api/index.d.ts +1 -1
- package/lib/api/index.js +1 -1
- package/lib/api/shared.d.ts +33 -5
- package/lib/api/shared.js +2 -7
- package/lib/api/utils/constants.d.ts +1 -30
- package/lib/api/utils/constants.js +2 -41
- package/lib/api/utils/types.d.ts +1 -320
- package/lib/api/utils/utils.d.ts +0 -38
- package/lib/api/utils/utils.js +1 -139
- package/lib/builders/ActionRow.js +1 -1
- package/lib/builders/Attachment.d.ts +14 -6
- package/lib/builders/Attachment.js +30 -7
- package/lib/builders/Button.d.ts +5 -14
- package/lib/builders/Button.js +0 -11
- package/lib/builders/{MessageEmbed.d.ts → Embed.d.ts} +15 -15
- package/lib/builders/{MessageEmbed.js → Embed.js} +16 -16
- package/lib/builders/Modal.js +1 -1
- package/lib/builders/SelectMenu.d.ts +14 -15
- package/lib/builders/SelectMenu.js +19 -18
- package/lib/builders/index.d.ts +1 -1
- package/lib/builders/index.js +1 -1
- package/lib/builders/types.d.ts +2 -2
- package/lib/cache/adapters/default.d.ts +1 -0
- package/lib/cache/adapters/default.js +3 -2
- package/lib/cache/adapters/redis.d.ts +3 -3
- package/lib/cache/adapters/redis.js +14 -5
- package/lib/cache/adapters/types.d.ts +1 -0
- package/lib/cache/adapters/workeradapter.d.ts +10 -1
- package/lib/cache/adapters/workeradapter.js +8 -3
- package/lib/cache/index.d.ts +18 -5
- package/lib/cache/index.js +23 -9
- package/lib/cache/resources/channels.d.ts +6 -2
- package/lib/cache/resources/channels.js +12 -6
- package/lib/cache/resources/default/base.d.ts +17 -16
- package/lib/cache/resources/default/base.js +25 -24
- package/lib/cache/resources/default/guild-based.d.ts +22 -19
- package/lib/cache/resources/default/guild-based.js +32 -31
- package/lib/cache/resources/default/guild-related.d.ts +22 -19
- package/lib/cache/resources/default/guild-related.js +37 -43
- package/lib/cache/resources/emojis.d.ts +4 -2
- package/lib/cache/resources/emojis.js +8 -6
- package/lib/cache/resources/guilds.d.ts +4 -2
- package/lib/cache/resources/guilds.js +15 -8
- package/lib/cache/resources/members.d.ts +4 -2
- package/lib/cache/resources/members.js +16 -13
- package/lib/cache/resources/overwrites.d.ts +25 -0
- package/lib/cache/resources/overwrites.js +39 -0
- package/lib/cache/resources/presence.js +3 -4
- package/lib/cache/resources/roles.d.ts +4 -2
- package/lib/cache/resources/roles.js +8 -6
- package/lib/cache/resources/stickers.d.ts +4 -2
- package/lib/cache/resources/stickers.js +8 -6
- package/lib/cache/resources/threads.d.ts +4 -2
- package/lib/cache/resources/threads.js +8 -6
- package/lib/cache/resources/users.d.ts +4 -2
- package/lib/cache/resources/users.js +8 -6
- package/lib/cache/resources/voice-states.d.ts +3 -3
- package/lib/cache/resources/voice-states.js +6 -7
- package/lib/client/base.d.ts +48 -16
- package/lib/client/base.js +19 -15
- package/lib/client/client.d.ts +15 -4
- package/lib/client/client.js +26 -28
- package/lib/client/httpclient.d.ts +3 -5
- package/lib/client/httpclient.js +29 -16
- package/lib/client/{oninteraction.d.ts → oninteractioncreate.d.ts} +1 -1
- package/lib/client/{oninteraction.js → oninteractioncreate.js} +34 -23
- package/lib/client/onmessagecreate.d.ts +3 -0
- package/lib/client/onmessagecreate.js +337 -0
- package/lib/client/workerclient.d.ts +19 -2
- package/lib/client/workerclient.js +156 -46
- package/lib/collection.d.ts +1 -1
- package/lib/collection.js +9 -6
- package/lib/commands/applications/chat.d.ts +32 -25
- package/lib/commands/applications/chat.js +51 -34
- package/lib/commands/applications/chatcontext.d.ts +34 -16
- package/lib/commands/applications/chatcontext.js +99 -20
- package/lib/commands/applications/menu.d.ts +9 -8
- package/lib/commands/applications/menu.js +14 -5
- package/lib/commands/applications/menucontext.d.ts +27 -10
- package/lib/commands/applications/menucontext.js +51 -7
- package/lib/commands/applications/options.d.ts +13 -13
- package/lib/commands/applications/shared.d.ts +7 -2
- package/lib/commands/decorators.d.ts +14 -14
- package/lib/commands/decorators.js +9 -5
- package/lib/commands/handler.d.ts +2 -1
- package/lib/commands/handler.js +60 -14
- package/lib/commands/index.d.ts +1 -1
- package/lib/commands/index.js +2 -1
- package/lib/commands/optionresolver.d.ts +6 -5
- package/lib/commands/optionresolver.js +10 -6
- package/lib/common/bot/watcher.d.ts +3 -3
- package/lib/common/bot/watcher.js +3 -1
- package/lib/common/index.d.ts +1 -1
- package/lib/common/index.js +2 -1
- package/lib/common/it/logger.d.ts +11 -0
- package/lib/common/it/logger.js +51 -2
- package/lib/common/it/utils.d.ts +3 -13
- package/lib/common/it/utils.js +9 -30
- package/lib/common/shorters/channels.d.ts +55 -5
- package/lib/common/shorters/channels.js +59 -0
- package/lib/common/shorters/guilds.d.ts +5 -2
- package/lib/common/shorters/guilds.js +18 -0
- package/lib/common/shorters/messages.js +0 -2
- package/lib/common/shorters/overwrites.d.ts +29 -0
- package/lib/common/shorters/overwrites.js +63 -0
- package/lib/common/shorters/roles.js +3 -3
- package/lib/common/shorters/webhook.d.ts +2 -2
- package/lib/common/types/util.d.ts +3 -2
- package/lib/common/types/write.d.ts +3 -7
- package/lib/components/handler.d.ts +11 -17
- package/lib/components/handler.js +45 -93
- package/lib/components/index.d.ts +0 -1
- package/lib/components/index.js +0 -1
- package/lib/components/listener.d.ts +2 -2
- package/lib/components/listener.js +2 -3
- package/lib/events/event.d.ts +2 -2
- package/lib/events/handler.d.ts +3 -2
- package/lib/events/handler.js +14 -6
- package/lib/events/hooks/dispatch.d.ts +2 -1
- package/lib/events/hooks/dispatch.js +5 -1
- package/lib/events/hooks/thread.d.ts +63 -63
- package/lib/index.d.ts +8 -5
- package/lib/index.js +20 -10
- package/lib/langs/handler.d.ts +6 -4
- package/lib/langs/handler.js +10 -8
- package/lib/langs/router.d.ts +8 -9
- package/lib/langs/router.js +5 -5
- package/lib/structures/ClientUser.d.ts +1 -16
- package/lib/structures/ClientUser.js +0 -31
- package/lib/structures/Guild.d.ts +1 -1
- package/lib/structures/GuildMember.d.ts +12 -0
- package/lib/structures/GuildMember.js +14 -0
- package/lib/structures/GuildRole.d.ts +4 -2
- package/lib/structures/GuildRole.js +4 -1
- package/lib/structures/GuildTemplate.js +1 -1
- package/lib/structures/Interaction.d.ts +2 -0
- package/lib/structures/Interaction.js +12 -13
- package/lib/structures/Message.d.ts +7 -2
- package/lib/structures/Message.js +6 -3
- package/lib/structures/Sticker.d.ts +1 -1
- package/lib/structures/Sticker.js +1 -1
- package/lib/structures/User.d.ts +5 -0
- package/lib/structures/User.js +3 -0
- package/lib/structures/Webhook.d.ts +1 -1
- package/lib/structures/Webhook.js +1 -1
- package/lib/structures/channels.d.ts +45 -6
- package/lib/structures/channels.js +23 -7
- package/lib/structures/extra/BitField.d.ts +9 -6
- package/lib/structures/extra/BitField.js +27 -3
- package/lib/structures/extra/Permissions.d.ts +6 -1
- package/lib/structures/extra/Permissions.js +7 -0
- package/lib/websocket/constants/index.js +1 -3
- package/lib/websocket/discord/basesocket.js +0 -1
- package/lib/websocket/discord/shared.d.ts +2 -0
- package/lib/websocket/discord/worker.d.ts +23 -7
- package/lib/websocket/discord/workermanager.d.ts +32 -5
- package/lib/websocket/discord/workermanager.js +98 -29
- package/package.json +23 -21
- package/lib/api/REST.d.ts +0 -127
- package/lib/api/REST.js +0 -424
- package/lib/api/errors/DiscordAPIError.d.ts +0 -51
- package/lib/api/errors/DiscordAPIError.js +0 -81
- package/lib/api/errors/HTTPError.d.ts +0 -20
- package/lib/api/errors/HTTPError.js +0 -28
- package/lib/api/errors/RateLimitError.d.ts +0 -19
- package/lib/api/errors/RateLimitError.js +0 -37
- package/lib/api/handlers/BurstHandler.d.ts +0 -51
- package/lib/api/handlers/BurstHandler.js +0 -124
- package/lib/api/handlers/SequentialHandler.d.ts +0 -81
- package/lib/api/handlers/SequentialHandler.js +0 -365
- package/lib/api/handlers/Shared.d.ts +0 -14
- package/lib/api/handlers/Shared.js +0 -125
- package/lib/api/interfaces/Handler.d.ts +0 -21
- package/lib/api/interfaces/Handler.js +0 -2
- package/lib/websocket/discord/handlemessage.d.ts +0 -0
- package/lib/websocket/discord/handlemessage.js +0 -1
- package/lib/websocket/discord/memberUpdate.d.ts +0 -16
- package/lib/websocket/discord/memberUpdate.js +0 -47
package/lib/api/utils/utils.js
CHANGED
|
@@ -1,117 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const RateLimitError_js_1 = require("../errors/RateLimitError.js");
|
|
5
|
-
const constants_js_1 = require("./constants.js");
|
|
6
|
-
const types_js_1 = require("./types.js");
|
|
7
|
-
function serializeSearchParam(value) {
|
|
8
|
-
switch (typeof value) {
|
|
9
|
-
case 'string':
|
|
10
|
-
return value;
|
|
11
|
-
case 'number':
|
|
12
|
-
case 'bigint':
|
|
13
|
-
case 'boolean':
|
|
14
|
-
return value.toString();
|
|
15
|
-
case 'object':
|
|
16
|
-
if (value === null)
|
|
17
|
-
return null;
|
|
18
|
-
if (value instanceof Date) {
|
|
19
|
-
return Number.isNaN(value.getTime()) ? null : value.toISOString();
|
|
20
|
-
}
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
22
|
-
if (typeof value.toString === 'function' && value.toString !== Object.prototype.toString)
|
|
23
|
-
return value.toString();
|
|
24
|
-
return null;
|
|
25
|
-
default:
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Creates and populates an URLSearchParams instance from an object, stripping
|
|
31
|
-
* out null and undefined values, while also coercing non-strings to strings.
|
|
32
|
-
*
|
|
33
|
-
* @param options - The options to use
|
|
34
|
-
* @returns A populated URLSearchParams instance
|
|
35
|
-
*/
|
|
36
|
-
function makeURLSearchParams(options) {
|
|
37
|
-
const params = new URLSearchParams();
|
|
38
|
-
if (!options)
|
|
39
|
-
return params;
|
|
40
|
-
for (const [key, value] of Object.entries(options)) {
|
|
41
|
-
const serialized = serializeSearchParam(value);
|
|
42
|
-
if (serialized !== null)
|
|
43
|
-
params.append(key, serialized);
|
|
44
|
-
}
|
|
45
|
-
return params;
|
|
46
|
-
}
|
|
47
|
-
exports.makeURLSearchParams = makeURLSearchParams;
|
|
48
|
-
/**
|
|
49
|
-
* Converts the response to usable data
|
|
50
|
-
*
|
|
51
|
-
* @param res - The fetch response
|
|
52
|
-
*/
|
|
53
|
-
async function parseResponse(res) {
|
|
54
|
-
if (res.headers.get('Content-Type')?.startsWith('application/json')) {
|
|
55
|
-
return res.json();
|
|
56
|
-
}
|
|
57
|
-
return res.arrayBuffer();
|
|
58
|
-
}
|
|
59
|
-
exports.parseResponse = parseResponse;
|
|
60
|
-
/**
|
|
61
|
-
* Check whether a request falls under a sublimit
|
|
62
|
-
*
|
|
63
|
-
* @param bucketRoute - The buckets route identifier
|
|
64
|
-
* @param body - The options provided as JSON data
|
|
65
|
-
* @param method - The HTTP method that will be used to make the request
|
|
66
|
-
* @returns Whether the request falls under a sublimit
|
|
67
|
-
*/
|
|
68
|
-
function hasSublimit(bucketRoute, body, method) {
|
|
69
|
-
// TODO: Update for new sublimits
|
|
70
|
-
// Currently known sublimits:
|
|
71
|
-
// Editing channel `name` or `topic`
|
|
72
|
-
if (bucketRoute === '/channels/:id') {
|
|
73
|
-
if (typeof body !== 'object' || body === null)
|
|
74
|
-
return false;
|
|
75
|
-
// This should never be a POST body, but just in case
|
|
76
|
-
if (method !== types_js_1.RequestMethod.Patch)
|
|
77
|
-
return false;
|
|
78
|
-
const castedBody = body;
|
|
79
|
-
return ['name', 'topic'].some(key => Reflect.has(castedBody, key));
|
|
80
|
-
}
|
|
81
|
-
// If we are checking if a request has a sublimit on a route not checked above, sublimit all requests to avoid a flood of 429s
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
exports.hasSublimit = hasSublimit;
|
|
85
|
-
/**
|
|
86
|
-
* Check whether an error indicates that a retry can be attempted
|
|
87
|
-
*
|
|
88
|
-
* @param error - The error thrown by the network request
|
|
89
|
-
* @returns Whether the error indicates a retry should be attempted
|
|
90
|
-
*/
|
|
91
|
-
function shouldRetry(error) {
|
|
92
|
-
// Retry for possible timed out requests
|
|
93
|
-
if (error.name === 'AbortError')
|
|
94
|
-
return true;
|
|
95
|
-
// Downlevel ECONNRESET to retry as it may be recoverable
|
|
96
|
-
return ('code' in error && error.code === 'ECONNRESET') || error.message.includes('ECONNRESET');
|
|
97
|
-
}
|
|
98
|
-
exports.shouldRetry = shouldRetry;
|
|
99
|
-
/**
|
|
100
|
-
* Determines whether the request should be queued or whether a RateLimitError should be thrown
|
|
101
|
-
*
|
|
102
|
-
* @internal
|
|
103
|
-
*/
|
|
104
|
-
async function onRateLimit(manager, rateLimitData) {
|
|
105
|
-
if (!manager.options.rejectOnRateLimit)
|
|
106
|
-
return;
|
|
107
|
-
const shouldThrow = typeof manager.options.rejectOnRateLimit === 'function'
|
|
108
|
-
? await manager.options.rejectOnRateLimit(rateLimitData)
|
|
109
|
-
: manager.options.rejectOnRateLimit.some(route => rateLimitData.route.startsWith(route.toLowerCase()));
|
|
110
|
-
if (shouldThrow) {
|
|
111
|
-
throw new RateLimitError_js_1.RateLimitError(rateLimitData);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
exports.onRateLimit = onRateLimit;
|
|
3
|
+
exports.isBufferLike = exports.calculateUserDefaultAvatarIndex = void 0;
|
|
115
4
|
/**
|
|
116
5
|
* Calculates the default avatar index for a given user id.
|
|
117
6
|
*
|
|
@@ -121,17 +10,6 @@ function calculateUserDefaultAvatarIndex(userId) {
|
|
|
121
10
|
return Number(BigInt(userId) >> 22n) % 6;
|
|
122
11
|
}
|
|
123
12
|
exports.calculateUserDefaultAvatarIndex = calculateUserDefaultAvatarIndex;
|
|
124
|
-
/**
|
|
125
|
-
* Sleeps for a given amount of time.
|
|
126
|
-
*
|
|
127
|
-
* @param ms - The amount of time (in milliseconds) to sleep for
|
|
128
|
-
*/
|
|
129
|
-
async function sleep(ms) {
|
|
130
|
-
return new Promise(resolve => {
|
|
131
|
-
setTimeout(() => resolve(), ms);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
exports.sleep = sleep;
|
|
135
13
|
/**
|
|
136
14
|
* Verifies that a value is a buffer-like object.
|
|
137
15
|
*
|
|
@@ -141,19 +19,3 @@ function isBufferLike(value) {
|
|
|
141
19
|
return value instanceof ArrayBuffer || value instanceof Uint8Array || value instanceof Uint8ClampedArray;
|
|
142
20
|
}
|
|
143
21
|
exports.isBufferLike = isBufferLike;
|
|
144
|
-
/**
|
|
145
|
-
* Irrespective environment warning.
|
|
146
|
-
*
|
|
147
|
-
* @remarks Only the message is needed. The deprecation prefix is handled already.
|
|
148
|
-
* @param message - A string the warning will emit with
|
|
149
|
-
* @internal
|
|
150
|
-
*/
|
|
151
|
-
function deprecationWarning(message) {
|
|
152
|
-
if (typeof globalThis.process === 'undefined') {
|
|
153
|
-
console.warn(`${constants_js_1.DEPRECATION_WARNING_PREFIX}: ${message}`);
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
process.emitWarning(message, constants_js_1.DEPRECATION_WARNING_PREFIX);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
exports.deprecationWarning = deprecationWarning;
|
|
@@ -30,7 +30,7 @@ class ActionRow extends Base_1.BaseComponentBuilder {
|
|
|
30
30
|
* actionRow.addComponents([buttonComponent1, buttonComponent2]);
|
|
31
31
|
*/
|
|
32
32
|
addComponents(...component) {
|
|
33
|
-
this.components = this.components.concat(
|
|
33
|
+
this.components = this.components.concat(component.flat());
|
|
34
34
|
return this;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type { RESTAPIAttachment } from 'discord-api-types/v10';
|
|
2
|
+
import type { APIAttachment, RESTAPIAttachment } from 'discord-api-types/v10';
|
|
3
3
|
import { type RawFile } from '..';
|
|
4
|
-
import type {
|
|
4
|
+
import type { BaseClient } from '../client/base';
|
|
5
|
+
import type { ImageResolvable, ObjectToLower } from '../common';
|
|
6
|
+
import { Base } from '../structures/extra/Base';
|
|
5
7
|
export interface AttachmentResolvableMap {
|
|
6
8
|
url: string;
|
|
7
|
-
buffer: Buffer;
|
|
9
|
+
buffer: Buffer | ArrayBuffer;
|
|
8
10
|
path: string;
|
|
9
11
|
}
|
|
10
|
-
export type AttachmentResolvable = AttachmentResolvableMap[keyof AttachmentResolvableMap] | Attachment;
|
|
12
|
+
export type AttachmentResolvable = AttachmentResolvableMap[keyof AttachmentResolvableMap] | AttachmentBuilder | Attachment;
|
|
11
13
|
export type AttachmentDataType = keyof AttachmentResolvableMap;
|
|
12
14
|
export interface AttachmentData {
|
|
13
15
|
name: string;
|
|
@@ -15,7 +17,13 @@ export interface AttachmentData {
|
|
|
15
17
|
resolvable: AttachmentResolvable;
|
|
16
18
|
type: AttachmentDataType;
|
|
17
19
|
}
|
|
18
|
-
export
|
|
20
|
+
export interface Attachment extends ObjectToLower<APIAttachment> {
|
|
21
|
+
}
|
|
22
|
+
export declare class Attachment extends Base {
|
|
23
|
+
data: APIAttachment;
|
|
24
|
+
constructor(client: BaseClient, data: APIAttachment);
|
|
25
|
+
}
|
|
26
|
+
export declare class AttachmentBuilder {
|
|
19
27
|
data: Partial<AttachmentData>;
|
|
20
28
|
/**
|
|
21
29
|
* Creates a new Attachment instance.
|
|
@@ -78,7 +86,7 @@ export declare function resolveAttachment(resolve: Attachment | AttachmentData |
|
|
|
78
86
|
* @param resources - The list of attachments to resolve.
|
|
79
87
|
* @returns The resolved raw files.
|
|
80
88
|
*/
|
|
81
|
-
export declare function resolveFiles(resources: (
|
|
89
|
+
export declare function resolveFiles(resources: (AttachmentBuilder | RawFile | Attachment)[]): Promise<RawFile[]>;
|
|
82
90
|
/**
|
|
83
91
|
* Resolves the data of an attachment.
|
|
84
92
|
* @param data - The resolvable data of the attachment.
|
|
@@ -3,12 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.resolveImage = exports.resolveBase64 = exports.resolveAttachmentData = exports.resolveFiles = exports.resolveAttachment = exports.Attachment = void 0;
|
|
6
|
+
exports.resolveImage = exports.resolveBase64 = exports.resolveAttachmentData = exports.resolveFiles = exports.resolveAttachment = exports.AttachmentBuilder = exports.Attachment = void 0;
|
|
7
7
|
const node_crypto_1 = require("node:crypto");
|
|
8
8
|
const promises_1 = require("node:fs/promises");
|
|
9
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
10
|
const __1 = require("..");
|
|
11
|
-
|
|
11
|
+
const Base_1 = require("../structures/extra/Base");
|
|
12
|
+
class Attachment extends Base_1.Base {
|
|
13
|
+
data;
|
|
14
|
+
constructor(client, data) {
|
|
15
|
+
super(client);
|
|
16
|
+
this.data = data;
|
|
17
|
+
this.__patchThis(data);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.Attachment = Attachment;
|
|
21
|
+
class AttachmentBuilder {
|
|
12
22
|
data;
|
|
13
23
|
/**
|
|
14
24
|
* Creates a new Attachment instance.
|
|
@@ -85,7 +95,7 @@ class Attachment {
|
|
|
85
95
|
return this.data;
|
|
86
96
|
}
|
|
87
97
|
}
|
|
88
|
-
exports.
|
|
98
|
+
exports.AttachmentBuilder = AttachmentBuilder;
|
|
89
99
|
/**
|
|
90
100
|
* Resolves an attachment to a REST API attachment.
|
|
91
101
|
* @param resolve - The attachment or attachment data to resolve.
|
|
@@ -94,7 +104,7 @@ exports.Attachment = Attachment;
|
|
|
94
104
|
function resolveAttachment(resolve) {
|
|
95
105
|
if ('id' in resolve)
|
|
96
106
|
return resolve;
|
|
97
|
-
if (resolve instanceof
|
|
107
|
+
if (resolve instanceof AttachmentBuilder) {
|
|
98
108
|
const data = resolve.toJSON();
|
|
99
109
|
return { filename: data.name, description: data.description };
|
|
100
110
|
}
|
|
@@ -108,11 +118,20 @@ exports.resolveAttachment = resolveAttachment;
|
|
|
108
118
|
*/
|
|
109
119
|
async function resolveFiles(resources) {
|
|
110
120
|
const data = await Promise.all(resources.map(async (resource, i) => {
|
|
111
|
-
if (resource instanceof
|
|
121
|
+
if (resource instanceof AttachmentBuilder) {
|
|
112
122
|
const { type, resolvable, name } = resource.toJSON();
|
|
113
123
|
const resolve = await resolveAttachmentData(resolvable, type);
|
|
114
124
|
return { ...resolve, key: `files[${i}]`, name };
|
|
115
125
|
}
|
|
126
|
+
if (resource instanceof Attachment) {
|
|
127
|
+
const resolve = await resolveAttachmentData(resource.url, 'url');
|
|
128
|
+
return {
|
|
129
|
+
data: resolve.data,
|
|
130
|
+
contentType: resolve.contentType,
|
|
131
|
+
key: `files[${i}]`,
|
|
132
|
+
name: resource.filename,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
116
135
|
return {
|
|
117
136
|
data: resource.data,
|
|
118
137
|
contentType: resource.contentType,
|
|
@@ -130,7 +149,7 @@ exports.resolveFiles = resolveFiles;
|
|
|
130
149
|
* @returns The resolved attachment data.
|
|
131
150
|
*/
|
|
132
151
|
async function resolveAttachmentData(data, type) {
|
|
133
|
-
if (data instanceof
|
|
152
|
+
if (data instanceof AttachmentBuilder) {
|
|
134
153
|
if (!data.data.resolvable)
|
|
135
154
|
return (0, __1.throwError)('The attachment type has been expressed as attachment but cannot be resolved as one.');
|
|
136
155
|
return { data: data.data.resolvable };
|
|
@@ -184,12 +203,16 @@ exports.resolveBase64 = resolveBase64;
|
|
|
184
203
|
* @returns The resolved base64 data URL.
|
|
185
204
|
*/
|
|
186
205
|
async function resolveImage(image) {
|
|
187
|
-
if (image instanceof
|
|
206
|
+
if (image instanceof AttachmentBuilder) {
|
|
188
207
|
const { data: { type, resolvable }, } = image;
|
|
189
208
|
if (type && resolvable)
|
|
190
209
|
return resolveBase64((await resolveAttachmentData(resolvable, type)).data);
|
|
191
210
|
return (0, __1.throwError)(`The attachment type has been expressed as ${(type ?? 'Attachment').toUpperCase()} but cannot be resolved as one.`);
|
|
192
211
|
}
|
|
212
|
+
if (image instanceof Attachment) {
|
|
213
|
+
const response = await fetch(image.url);
|
|
214
|
+
return resolveBase64((await resolveAttachmentData(await response.arrayBuffer(), 'buffer')).data);
|
|
215
|
+
}
|
|
193
216
|
const file = await resolveAttachmentData(image.data, image.type);
|
|
194
217
|
return resolveBase64(file.data);
|
|
195
218
|
}
|
package/lib/builders/Button.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type { ButtonInteraction } from '../structures';
|
|
3
|
-
import type { ComponentCallback } from './types';
|
|
1
|
+
import { type APIButtonComponentWithCustomId, type APIButtonComponentWithURL, type ButtonStyle, type EmojiResolvable, type When } from '../common';
|
|
4
2
|
export type ButtonStylesForID = Exclude<ButtonStyle, ButtonStyle.Link>;
|
|
5
3
|
/**
|
|
6
4
|
* Represents a button component.
|
|
@@ -18,13 +16,13 @@ export declare class Button<Type extends boolean = boolean> {
|
|
|
18
16
|
* @param id - The custom ID to set.
|
|
19
17
|
* @returns The modified Button instance.
|
|
20
18
|
*/
|
|
21
|
-
setCustomId(id: string):
|
|
19
|
+
setCustomId(id: string): this;
|
|
22
20
|
/**
|
|
23
21
|
* Sets the URL for the button.
|
|
24
22
|
* @param url - The URL to set.
|
|
25
23
|
* @returns The modified Button instance.
|
|
26
24
|
*/
|
|
27
|
-
setURL(url: string):
|
|
25
|
+
setURL(url: string): this;
|
|
28
26
|
/**
|
|
29
27
|
* Sets the label for the button.
|
|
30
28
|
* @param label - The label to set.
|
|
@@ -43,17 +41,10 @@ export declare class Button<Type extends boolean = boolean> {
|
|
|
43
41
|
* @returns The modified Button instance.
|
|
44
42
|
*/
|
|
45
43
|
setDisabled(disabled?: boolean): this;
|
|
46
|
-
setStyle(style: ButtonStyle
|
|
47
|
-
setStyle(style: ButtonStylesForID): Omit<this, 'setURL'>;
|
|
48
|
-
/**
|
|
49
|
-
* Sets the callback function to be executed when the button is interacted with.
|
|
50
|
-
* @param func - The callback function to set.
|
|
51
|
-
* @returns The modified Button instance.
|
|
52
|
-
*/
|
|
53
|
-
run(func: ComponentCallback<ButtonInteraction>): Omit<this, 'setURL'>;
|
|
44
|
+
setStyle(style: ButtonStyle): this;
|
|
54
45
|
/**
|
|
55
46
|
* Converts the Button instance to its JSON representation.
|
|
56
47
|
* @returns The JSON representation of the Button instance.
|
|
57
48
|
*/
|
|
58
|
-
toJSON():
|
|
49
|
+
toJSON(): When<Type, APIButtonComponentWithCustomId, APIButtonComponentWithURL>;
|
|
59
50
|
}
|
package/lib/builders/Button.js
CHANGED
|
@@ -10,8 +10,6 @@ const functions_1 = require("../structures/extra/functions");
|
|
|
10
10
|
*/
|
|
11
11
|
class Button {
|
|
12
12
|
data;
|
|
13
|
-
/** @internal */
|
|
14
|
-
__exec;
|
|
15
13
|
/**
|
|
16
14
|
* Creates a new Button instance.
|
|
17
15
|
* @param data - The initial data for the button.
|
|
@@ -74,15 +72,6 @@ class Button {
|
|
|
74
72
|
this.data.style = style;
|
|
75
73
|
return this;
|
|
76
74
|
}
|
|
77
|
-
/**
|
|
78
|
-
* Sets the callback function to be executed when the button is interacted with.
|
|
79
|
-
* @param func - The callback function to set.
|
|
80
|
-
* @returns The modified Button instance.
|
|
81
|
-
*/
|
|
82
|
-
run(func) {
|
|
83
|
-
this.__exec = func;
|
|
84
|
-
return this;
|
|
85
|
-
}
|
|
86
75
|
/**
|
|
87
76
|
* Converts the Button instance to its JSON representation.
|
|
88
77
|
* @returns The JSON representation of the Button instance.
|
|
@@ -2,7 +2,7 @@ import { type APIEmbed, type APIEmbedAuthor, type APIEmbedField, type APIEmbedFo
|
|
|
2
2
|
/**
|
|
3
3
|
* Represents a message embed.
|
|
4
4
|
* @example
|
|
5
|
-
* const embed = new
|
|
5
|
+
* const embed = new Embed();
|
|
6
6
|
* embed.setTitle('Seyfert');
|
|
7
7
|
* embed.setDescription('Better than discord.js');
|
|
8
8
|
* embed.setColor('Green');
|
|
@@ -11,16 +11,16 @@ import { type APIEmbed, type APIEmbedAuthor, type APIEmbedField, type APIEmbedFo
|
|
|
11
11
|
export declare class Embed {
|
|
12
12
|
data: Partial<APIEmbed>;
|
|
13
13
|
/**
|
|
14
|
-
* Creates a new instance of
|
|
14
|
+
* Creates a new instance of Embed.
|
|
15
15
|
* @param data - The initial data for the embed.
|
|
16
16
|
* @example
|
|
17
|
-
* const embed = new
|
|
17
|
+
* const embed = new Embed({ title: 'Hello', description: 'This is an example embed' });
|
|
18
18
|
*/
|
|
19
19
|
constructor(data?: Partial<APIEmbed>);
|
|
20
20
|
/**
|
|
21
21
|
* Sets the author of the embed.
|
|
22
22
|
* @param author - The author information.
|
|
23
|
-
* @returns The updated
|
|
23
|
+
* @returns The updated Embed instance.
|
|
24
24
|
* @example
|
|
25
25
|
* embed.setAuthor({ name: 'John Doe', iconURL: 'https://example.com/avatar.png' });
|
|
26
26
|
*/
|
|
@@ -28,7 +28,7 @@ export declare class Embed {
|
|
|
28
28
|
/**
|
|
29
29
|
* Sets the color of the embed.
|
|
30
30
|
* @param color - The color of the embed.
|
|
31
|
-
* @returns The updated
|
|
31
|
+
* @returns The updated Embed instance.
|
|
32
32
|
* @example
|
|
33
33
|
* embed.setColor('#FF0000');
|
|
34
34
|
* embed.setColor('Blurple');
|
|
@@ -37,7 +37,7 @@ export declare class Embed {
|
|
|
37
37
|
/**
|
|
38
38
|
* Sets the description of the embed.
|
|
39
39
|
* @param desc - The description of the embed.
|
|
40
|
-
* @returns The updated
|
|
40
|
+
* @returns The updated Embed instance.
|
|
41
41
|
* @example
|
|
42
42
|
* embed.setDescription('This is the description of the embed');
|
|
43
43
|
*/
|
|
@@ -45,7 +45,7 @@ export declare class Embed {
|
|
|
45
45
|
/**
|
|
46
46
|
* Adds one or more fields to the embed.
|
|
47
47
|
* @param fields - The fields to add to the embed.
|
|
48
|
-
* @returns The updated
|
|
48
|
+
* @returns The updated Embed instance.
|
|
49
49
|
* @example
|
|
50
50
|
* embed.addFields({ name: 'Field 1', value: 'Value 1' }, { name: 'Field 2', value: 'Value 2' });
|
|
51
51
|
*/
|
|
@@ -53,7 +53,7 @@ export declare class Embed {
|
|
|
53
53
|
/**
|
|
54
54
|
* Sets the fields of the embed.
|
|
55
55
|
* @param fields - The fields of the embed.
|
|
56
|
-
* @returns The updated
|
|
56
|
+
* @returns The updated Embed instance.
|
|
57
57
|
* @example
|
|
58
58
|
* embed.setFields([{ name: 'Field 1', value: 'Value 1' }, { name: 'Field 2', value: 'Value 2' }]);
|
|
59
59
|
*/
|
|
@@ -61,7 +61,7 @@ export declare class Embed {
|
|
|
61
61
|
/**
|
|
62
62
|
* Sets the footer of the embed.
|
|
63
63
|
* @param footer - The footer information.
|
|
64
|
-
* @returns The updated
|
|
64
|
+
* @returns The updated Embed instance.
|
|
65
65
|
* @example
|
|
66
66
|
* embed.setFooter({ text: 'This is the footer', iconURL: 'https://example.com/footer.png' });
|
|
67
67
|
*/
|
|
@@ -69,7 +69,7 @@ export declare class Embed {
|
|
|
69
69
|
/**
|
|
70
70
|
* Sets the image of the embed.
|
|
71
71
|
* @param url - The URL of the image.
|
|
72
|
-
* @returns The updated
|
|
72
|
+
* @returns The updated Embed instance.
|
|
73
73
|
* @example
|
|
74
74
|
* embed.setImage('https://example.com/image.png');
|
|
75
75
|
*/
|
|
@@ -77,7 +77,7 @@ export declare class Embed {
|
|
|
77
77
|
/**
|
|
78
78
|
* Sets the timestamp of the embed.
|
|
79
79
|
* @param time - The timestamp value.
|
|
80
|
-
* @returns The updated
|
|
80
|
+
* @returns The updated Embed instance.
|
|
81
81
|
* @example
|
|
82
82
|
* embed.setTimestamp();
|
|
83
83
|
* embed.setTimestamp(1628761200000);
|
|
@@ -87,7 +87,7 @@ export declare class Embed {
|
|
|
87
87
|
/**
|
|
88
88
|
* Sets the title of the embed.
|
|
89
89
|
* @param title - The title of the embed.
|
|
90
|
-
* @returns The updated
|
|
90
|
+
* @returns The updated Embed instance.
|
|
91
91
|
* @example
|
|
92
92
|
* embed.setTitle('This is the title');
|
|
93
93
|
*/
|
|
@@ -95,7 +95,7 @@ export declare class Embed {
|
|
|
95
95
|
/**
|
|
96
96
|
* Sets the URL of the embed.
|
|
97
97
|
* @param url - The URL of the embed.
|
|
98
|
-
* @returns The updated
|
|
98
|
+
* @returns The updated Embed instance.
|
|
99
99
|
* @example
|
|
100
100
|
* embed.setURL('https://seyfert.com');
|
|
101
101
|
*/
|
|
@@ -103,13 +103,13 @@ export declare class Embed {
|
|
|
103
103
|
/**
|
|
104
104
|
* Sets the thumbnail of the embed.
|
|
105
105
|
* @param url - The URL of the thumbnail.
|
|
106
|
-
* @returns The updated
|
|
106
|
+
* @returns The updated Embed instance.
|
|
107
107
|
* @example
|
|
108
108
|
* embed.setThumbnail('https://example.com/thumbnail.png');
|
|
109
109
|
*/
|
|
110
110
|
setThumbnail(url?: string): this;
|
|
111
111
|
/**
|
|
112
|
-
* Converts the
|
|
112
|
+
* Converts the Embed instance to a JSON object.
|
|
113
113
|
* @returns The JSON representation of the MessageEmbed instance.
|
|
114
114
|
*/
|
|
115
115
|
toJSON(): APIEmbed;
|
|
@@ -5,7 +5,7 @@ const common_1 = require("../common");
|
|
|
5
5
|
/**
|
|
6
6
|
* Represents a message embed.
|
|
7
7
|
* @example
|
|
8
|
-
* const embed = new
|
|
8
|
+
* const embed = new Embed();
|
|
9
9
|
* embed.setTitle('Seyfert');
|
|
10
10
|
* embed.setDescription('Better than discord.js');
|
|
11
11
|
* embed.setColor('Green');
|
|
@@ -14,10 +14,10 @@ const common_1 = require("../common");
|
|
|
14
14
|
class Embed {
|
|
15
15
|
data;
|
|
16
16
|
/**
|
|
17
|
-
* Creates a new instance of
|
|
17
|
+
* Creates a new instance of Embed.
|
|
18
18
|
* @param data - The initial data for the embed.
|
|
19
19
|
* @example
|
|
20
|
-
* const embed = new
|
|
20
|
+
* const embed = new Embed({ title: 'Hello', description: 'This is an example embed' });
|
|
21
21
|
*/
|
|
22
22
|
constructor(data = {}) {
|
|
23
23
|
this.data = data;
|
|
@@ -27,7 +27,7 @@ class Embed {
|
|
|
27
27
|
/**
|
|
28
28
|
* Sets the author of the embed.
|
|
29
29
|
* @param author - The author information.
|
|
30
|
-
* @returns The updated
|
|
30
|
+
* @returns The updated Embed instance.
|
|
31
31
|
* @example
|
|
32
32
|
* embed.setAuthor({ name: 'John Doe', iconURL: 'https://example.com/avatar.png' });
|
|
33
33
|
*/
|
|
@@ -38,7 +38,7 @@ class Embed {
|
|
|
38
38
|
/**
|
|
39
39
|
* Sets the color of the embed.
|
|
40
40
|
* @param color - The color of the embed.
|
|
41
|
-
* @returns The updated
|
|
41
|
+
* @returns The updated Embed instance.
|
|
42
42
|
* @example
|
|
43
43
|
* embed.setColor('#FF0000');
|
|
44
44
|
* embed.setColor('Blurple');
|
|
@@ -50,7 +50,7 @@ class Embed {
|
|
|
50
50
|
/**
|
|
51
51
|
* Sets the description of the embed.
|
|
52
52
|
* @param desc - The description of the embed.
|
|
53
|
-
* @returns The updated
|
|
53
|
+
* @returns The updated Embed instance.
|
|
54
54
|
* @example
|
|
55
55
|
* embed.setDescription('This is the description of the embed');
|
|
56
56
|
*/
|
|
@@ -61,18 +61,18 @@ class Embed {
|
|
|
61
61
|
/**
|
|
62
62
|
* Adds one or more fields to the embed.
|
|
63
63
|
* @param fields - The fields to add to the embed.
|
|
64
|
-
* @returns The updated
|
|
64
|
+
* @returns The updated Embed instance.
|
|
65
65
|
* @example
|
|
66
66
|
* embed.addFields({ name: 'Field 1', value: 'Value 1' }, { name: 'Field 2', value: 'Value 2' });
|
|
67
67
|
*/
|
|
68
68
|
addFields(...fields) {
|
|
69
|
-
this.data.fields = this.data.fields.concat(
|
|
69
|
+
this.data.fields = this.data.fields.concat(fields.flat());
|
|
70
70
|
return this;
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* Sets the fields of the embed.
|
|
74
74
|
* @param fields - The fields of the embed.
|
|
75
|
-
* @returns The updated
|
|
75
|
+
* @returns The updated Embed instance.
|
|
76
76
|
* @example
|
|
77
77
|
* embed.setFields([{ name: 'Field 1', value: 'Value 1' }, { name: 'Field 2', value: 'Value 2' }]);
|
|
78
78
|
*/
|
|
@@ -83,7 +83,7 @@ class Embed {
|
|
|
83
83
|
/**
|
|
84
84
|
* Sets the footer of the embed.
|
|
85
85
|
* @param footer - The footer information.
|
|
86
|
-
* @returns The updated
|
|
86
|
+
* @returns The updated Embed instance.
|
|
87
87
|
* @example
|
|
88
88
|
* embed.setFooter({ text: 'This is the footer', iconURL: 'https://example.com/footer.png' });
|
|
89
89
|
*/
|
|
@@ -94,7 +94,7 @@ class Embed {
|
|
|
94
94
|
/**
|
|
95
95
|
* Sets the image of the embed.
|
|
96
96
|
* @param url - The URL of the image.
|
|
97
|
-
* @returns The updated
|
|
97
|
+
* @returns The updated Embed instance.
|
|
98
98
|
* @example
|
|
99
99
|
* embed.setImage('https://example.com/image.png');
|
|
100
100
|
*/
|
|
@@ -105,7 +105,7 @@ class Embed {
|
|
|
105
105
|
/**
|
|
106
106
|
* Sets the timestamp of the embed.
|
|
107
107
|
* @param time - The timestamp value.
|
|
108
|
-
* @returns The updated
|
|
108
|
+
* @returns The updated Embed instance.
|
|
109
109
|
* @example
|
|
110
110
|
* embed.setTimestamp();
|
|
111
111
|
* embed.setTimestamp(1628761200000);
|
|
@@ -118,7 +118,7 @@ class Embed {
|
|
|
118
118
|
/**
|
|
119
119
|
* Sets the title of the embed.
|
|
120
120
|
* @param title - The title of the embed.
|
|
121
|
-
* @returns The updated
|
|
121
|
+
* @returns The updated Embed instance.
|
|
122
122
|
* @example
|
|
123
123
|
* embed.setTitle('This is the title');
|
|
124
124
|
*/
|
|
@@ -129,7 +129,7 @@ class Embed {
|
|
|
129
129
|
/**
|
|
130
130
|
* Sets the URL of the embed.
|
|
131
131
|
* @param url - The URL of the embed.
|
|
132
|
-
* @returns The updated
|
|
132
|
+
* @returns The updated Embed instance.
|
|
133
133
|
* @example
|
|
134
134
|
* embed.setURL('https://seyfert.com');
|
|
135
135
|
*/
|
|
@@ -140,7 +140,7 @@ class Embed {
|
|
|
140
140
|
/**
|
|
141
141
|
* Sets the thumbnail of the embed.
|
|
142
142
|
* @param url - The URL of the thumbnail.
|
|
143
|
-
* @returns The updated
|
|
143
|
+
* @returns The updated Embed instance.
|
|
144
144
|
* @example
|
|
145
145
|
* embed.setThumbnail('https://example.com/thumbnail.png');
|
|
146
146
|
*/
|
|
@@ -149,7 +149,7 @@ class Embed {
|
|
|
149
149
|
return this;
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
|
-
* Converts the
|
|
152
|
+
* Converts the Embed instance to a JSON object.
|
|
153
153
|
* @returns The JSON representation of the MessageEmbed instance.
|
|
154
154
|
*/
|
|
155
155
|
toJSON() {
|
package/lib/builders/Modal.js
CHANGED
|
@@ -35,7 +35,7 @@ class Modal {
|
|
|
35
35
|
* @returns The current Modal instance.
|
|
36
36
|
*/
|
|
37
37
|
addComponents(...components) {
|
|
38
|
-
this.components = this.components.concat(
|
|
38
|
+
this.components = this.components.concat(components.flat());
|
|
39
39
|
return this;
|
|
40
40
|
}
|
|
41
41
|
/**
|