seyfert 0.1.0 → 1.0.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/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 +39 -0
- package/lib/api/api.js +318 -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 +31 -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 +3 -12
- 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.js +2 -2
- package/lib/cache/adapters/redis.d.ts +2 -3
- package/lib/cache/adapters/redis.js +13 -5
- package/lib/cache/adapters/workeradapter.d.ts +9 -1
- package/lib/cache/adapters/workeradapter.js +7 -3
- package/lib/cache/index.d.ts +20 -6
- package/lib/cache/index.js +26 -10
- 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 +49 -16
- package/lib/client/base.js +21 -17
- package/lib/client/client.d.ts +14 -3
- package/lib/client/client.js +21 -21
- 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 +5 -1
- package/lib/client/workerclient.js +67 -44
- 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 +2 -1
- package/lib/common/types/write.d.ts +3 -7
- package/lib/components/handler.d.ts +12 -18
- package/lib/components/handler.js +58 -103
- 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/discord/basesocket.js +0 -1
- package/lib/websocket/discord/workermanager.d.ts +9 -1
- package/lib/websocket/discord/workermanager.js +21 -13
- package/package.json +21 -20
- 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/index.js
CHANGED
|
@@ -14,23 +14,33 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.extendContext = exports.config = exports.createEvent = exports.throwError = exports.WorkerManager = exports.ShardManager = exports.
|
|
17
|
+
exports.extendContext = exports.config = exports.createEvent = exports.throwError = exports.WorkerManager = exports.ShardManager = exports.LimitedCollection = exports.Collection = exports.Watcher = exports.PermissionFlagsBits = exports.Logger = void 0;
|
|
18
18
|
const common_1 = require("./common");
|
|
19
|
-
__exportStar(require("./api"), exports);
|
|
20
|
-
__exportStar(require("./builders"), exports);
|
|
21
|
-
__exportStar(require("./client"), exports);
|
|
22
|
-
__exportStar(require("./commands"), exports);
|
|
23
19
|
var common_2 = require("./common");
|
|
24
20
|
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return common_2.Logger; } });
|
|
21
|
+
Object.defineProperty(exports, "PermissionFlagsBits", { enumerable: true, get: function () { return common_2.PermissionFlagsBits; } });
|
|
25
22
|
Object.defineProperty(exports, "Watcher", { enumerable: true, get: function () { return common_2.Watcher; } });
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
Object.defineProperty(exports, "
|
|
29
|
-
Object.defineProperty(exports, "
|
|
30
|
-
|
|
23
|
+
//
|
|
24
|
+
var collection_1 = require("./collection");
|
|
25
|
+
Object.defineProperty(exports, "Collection", { enumerable: true, get: function () { return collection_1.Collection; } });
|
|
26
|
+
Object.defineProperty(exports, "LimitedCollection", { enumerable: true, get: function () { return collection_1.LimitedCollection; } });
|
|
27
|
+
//
|
|
28
|
+
__exportStar(require("./api"), exports);
|
|
29
|
+
__exportStar(require("./builders"), exports);
|
|
30
|
+
__exportStar(require("./cache"), exports);
|
|
31
|
+
__exportStar(require("./commands"), exports);
|
|
32
|
+
__exportStar(require("./components"), exports);
|
|
33
|
+
__exportStar(require("./events"), exports);
|
|
34
|
+
__exportStar(require("./langs"), exports);
|
|
35
|
+
//
|
|
31
36
|
var discord_1 = require("./websocket/discord");
|
|
32
37
|
Object.defineProperty(exports, "ShardManager", { enumerable: true, get: function () { return discord_1.ShardManager; } });
|
|
33
38
|
Object.defineProperty(exports, "WorkerManager", { enumerable: true, get: function () { return discord_1.WorkerManager; } });
|
|
39
|
+
//
|
|
40
|
+
__exportStar(require("./structures"), exports);
|
|
41
|
+
//
|
|
42
|
+
__exportStar(require("./client"), exports);
|
|
43
|
+
//
|
|
34
44
|
function throwError(msg) {
|
|
35
45
|
throw new Error(msg);
|
|
36
46
|
}
|
package/lib/langs/handler.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { BaseHandler } from '../common';
|
|
1
|
+
import { BaseHandler, type LocaleString } from '../common';
|
|
3
2
|
export declare class LangsHandler extends BaseHandler {
|
|
4
3
|
values: Partial<Record<string, any>>;
|
|
5
4
|
protected filter: (path: string) => boolean;
|
|
6
5
|
defaultLang?: string;
|
|
6
|
+
aliases: [string, LocaleString[]][];
|
|
7
|
+
getLocale(locale: string): string;
|
|
7
8
|
getKey(lang: string, message: string): string | undefined;
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
get(userLocale: string): import("./router").__InternalParseLocale<import("..").DefaultLocale> & {
|
|
10
|
+
get(locale?: string | undefined): import("..").DefaultLocale;
|
|
11
|
+
};
|
|
10
12
|
load(dir: string): Promise<void>;
|
|
11
13
|
}
|
package/lib/langs/handler.js
CHANGED
|
@@ -5,29 +5,31 @@ const common_1 = require("../common");
|
|
|
5
5
|
const router_1 = require("./router");
|
|
6
6
|
class LangsHandler extends common_1.BaseHandler {
|
|
7
7
|
values = {};
|
|
8
|
-
filter = (path) => path.endsWith('.js') || path.endsWith('.ts');
|
|
8
|
+
filter = (path) => path.endsWith('.js') || (!path.endsWith('.d.ts') && path.endsWith('.ts')) || path.endsWith('.json');
|
|
9
9
|
defaultLang;
|
|
10
|
+
aliases = [];
|
|
11
|
+
getLocale(locale) {
|
|
12
|
+
return this.aliases.find(([_key, aliases]) => aliases.includes(locale))?.[0] ?? locale;
|
|
13
|
+
}
|
|
10
14
|
getKey(lang, message) {
|
|
11
15
|
let value = this.values[lang];
|
|
12
16
|
for (const i of message.split('.')) {
|
|
13
17
|
value = value[i];
|
|
14
18
|
}
|
|
15
19
|
if (typeof value !== 'string') {
|
|
16
|
-
return
|
|
20
|
+
return;
|
|
17
21
|
}
|
|
18
22
|
return value;
|
|
19
23
|
}
|
|
20
|
-
parse(str, metadata) {
|
|
21
|
-
const regex = /{{(.*?)}}/g;
|
|
22
|
-
return str.replace(regex, match => metadata[match.slice(2, -2)] ?? match);
|
|
23
|
-
}
|
|
24
24
|
get(userLocale) {
|
|
25
|
-
|
|
25
|
+
const locale = this.getLocale(userLocale);
|
|
26
|
+
return (0, router_1.LangRouter)(locale, this.defaultLang ?? locale, this.values)();
|
|
26
27
|
}
|
|
27
28
|
async load(dir) {
|
|
28
29
|
const files = await this.loadFilesK(await this.getFiles(dir));
|
|
29
30
|
for (const i of files) {
|
|
30
|
-
|
|
31
|
+
const locale = i.name.split('.').slice(0, -1).join('.');
|
|
32
|
+
this.values[locale] = i.file;
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
}
|
package/lib/langs/router.d.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import type { DefaultLocale } from '../commands';
|
|
2
|
-
export declare const LangRouter: (userLocale: string, defaultLang: string, langs: Partial<Record<string, any>>) => (route?: string[], args?: any[]) => DefaultLocale
|
|
3
|
-
|
|
2
|
+
export declare const LangRouter: (userLocale: string, defaultLang: string, langs: Partial<Record<string, any>>) => (route?: string[], args?: any[]) => __InternalParseLocale<DefaultLocale> & {
|
|
3
|
+
get(locale?: string): DefaultLocale;
|
|
4
|
+
};
|
|
5
|
+
export type __InternalParseLocale<T extends Record<string, any>> = {
|
|
4
6
|
[K in keyof T]: T[K] extends (...args: any[]) => any ? (...args: Parameters<T[K]>) => {
|
|
5
|
-
get(locale?: string):
|
|
7
|
+
get(locale?: string): ReturnType<T[K]>;
|
|
6
8
|
} : T[K] extends string ? {
|
|
7
9
|
get(locale?: string): T[K];
|
|
8
10
|
} : T[K] extends unknown[] ? {
|
|
9
11
|
get(locale?: string): T[K];
|
|
10
|
-
} : T[K] extends Record<string, any> ?
|
|
12
|
+
} : T[K] extends Record<string, any> ? __InternalParseLocale<T[K]> & {
|
|
11
13
|
get(locale?: string): T[K];
|
|
12
14
|
} : never;
|
|
13
15
|
};
|
|
14
|
-
export type ParseLocales<T extends Record<string, any>> =
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
export {};
|
|
18
|
-
/**Code inspiration from: FreeAoi */
|
|
16
|
+
export type ParseLocales<T extends Record<string, any>> = T;
|
|
17
|
+
/**Idea inspiration from: FreeAoi */
|
package/lib/langs/router.js
CHANGED
|
@@ -18,14 +18,14 @@ const LangRouter = (userLocale, defaultLang, langs) => {
|
|
|
18
18
|
return value;
|
|
19
19
|
}
|
|
20
20
|
return (locale) => {
|
|
21
|
-
let
|
|
21
|
+
let result;
|
|
22
22
|
try {
|
|
23
|
-
|
|
23
|
+
result = getValue(locale ?? userLocale);
|
|
24
24
|
}
|
|
25
25
|
catch {
|
|
26
|
-
|
|
26
|
+
result = getValue(defaultLang);
|
|
27
27
|
}
|
|
28
|
-
const value = typeof
|
|
28
|
+
const value = typeof result === 'function' ? result(...args) : result;
|
|
29
29
|
return value;
|
|
30
30
|
};
|
|
31
31
|
}
|
|
@@ -39,4 +39,4 @@ const LangRouter = (userLocale, defaultLang, langs) => {
|
|
|
39
39
|
return createProxy;
|
|
40
40
|
};
|
|
41
41
|
exports.LangRouter = LangRouter;
|
|
42
|
-
/**
|
|
42
|
+
/**Idea inspiration from: FreeAoi */
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import type { BaseClient } from '../client/base';
|
|
2
|
-
import type { GatewayReadyDispatchData,
|
|
3
|
-
import { AnonymousGuild } from './AnonymousGuild';
|
|
4
|
-
import { Guild } from './Guild';
|
|
5
|
-
import { GuildMember } from './GuildMember';
|
|
2
|
+
import type { GatewayReadyDispatchData, RESTPatchAPICurrentUserJSONBody } from '../common';
|
|
6
3
|
import { User } from './User';
|
|
7
4
|
export declare class ClientUser extends User {
|
|
8
5
|
application: GatewayReadyDispatchData['application'];
|
|
@@ -10,16 +7,4 @@ export declare class ClientUser extends User {
|
|
|
10
7
|
constructor(client: BaseClient, data: GatewayReadyDispatchData['user'], application: GatewayReadyDispatchData['application']);
|
|
11
8
|
fetch(): Promise<ClientUser>;
|
|
12
9
|
edit(body: RESTPatchAPICurrentUserJSONBody): Promise<ClientUser>;
|
|
13
|
-
guilds: {
|
|
14
|
-
list: (query?: RESTGetAPICurrentUserGuildsQuery) => Promise<AnonymousGuild[]>;
|
|
15
|
-
fetch: (id: string) => Promise<Guild<"api">>;
|
|
16
|
-
fetchSelf: (id: string) => Promise<GuildMember>;
|
|
17
|
-
leave: (id: string) => Promise<void | undefined>;
|
|
18
|
-
};
|
|
19
|
-
static guilds(ctx: MethodContext): {
|
|
20
|
-
list: (query?: RESTGetAPICurrentUserGuildsQuery) => Promise<AnonymousGuild[]>;
|
|
21
|
-
fetch: (id: string) => Promise<Guild<"api">>;
|
|
22
|
-
fetchSelf: (id: string) => Promise<GuildMember>;
|
|
23
|
-
leave: (id: string) => Promise<void | undefined>;
|
|
24
|
-
};
|
|
25
10
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ClientUser = void 0;
|
|
4
|
-
const AnonymousGuild_1 = require("./AnonymousGuild");
|
|
5
|
-
const Guild_1 = require("./Guild");
|
|
6
|
-
const GuildMember_1 = require("./GuildMember");
|
|
7
4
|
const User_1 = require("./User");
|
|
8
5
|
class ClientUser extends User_1.User {
|
|
9
6
|
application;
|
|
@@ -20,33 +17,5 @@ class ClientUser extends User_1.User {
|
|
|
20
17
|
const data = await this.api.users('@me').patch({ body });
|
|
21
18
|
return new ClientUser(this.client, data, this.application);
|
|
22
19
|
}
|
|
23
|
-
guilds = ClientUser.guilds(this);
|
|
24
|
-
static guilds(ctx) {
|
|
25
|
-
return {
|
|
26
|
-
list: (query) => {
|
|
27
|
-
return ctx.client.proxy
|
|
28
|
-
.users('@me')
|
|
29
|
-
.guilds.get({ query })
|
|
30
|
-
.then(guilds => guilds.map(guild => new AnonymousGuild_1.AnonymousGuild(ctx.client, { ...guild, splash: null })));
|
|
31
|
-
},
|
|
32
|
-
fetch: async (id) => {
|
|
33
|
-
const guild = await ctx.client.proxy.guilds(id).get();
|
|
34
|
-
await ctx.client.cache.guilds?.patch(id, guild);
|
|
35
|
-
return new Guild_1.Guild(ctx.client, guild);
|
|
36
|
-
},
|
|
37
|
-
fetchSelf: async (id) => {
|
|
38
|
-
const self = await ctx.client.proxy.users('@me').guilds(id).member.get();
|
|
39
|
-
await ctx.client.cache.members?.patch(self.user.id, id, self);
|
|
40
|
-
return new GuildMember_1.GuildMember(ctx.client, self, self.user, id);
|
|
41
|
-
},
|
|
42
|
-
leave: (id) => {
|
|
43
|
-
return ctx.client.proxy
|
|
44
|
-
.users('@me')
|
|
45
|
-
.guilds(id)
|
|
46
|
-
.delete()
|
|
47
|
-
.then(() => ctx.client.cache.guilds?.removeIfNI('Guilds', id));
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
20
|
}
|
|
52
21
|
exports.ClientUser = ClientUser;
|
|
@@ -21,7 +21,7 @@ export declare class Guild<State extends StructStates = 'api'> extends Guild_bas
|
|
|
21
21
|
};
|
|
22
22
|
get maxStickers(): MaxStickers;
|
|
23
23
|
get maxEmojis(): MaxEmojis;
|
|
24
|
-
fetchOwner(force?: boolean): Promise<
|
|
24
|
+
fetchOwner(force?: boolean): Promise<null> | Promise<GuildMember>;
|
|
25
25
|
templates: {
|
|
26
26
|
fetch: (code: string) => Promise<import("discord-api-types/payloads/v10/template").APITemplate>;
|
|
27
27
|
list: () => Promise<import("discord-api-types/rest/v10/template").RESTGetAPIGuildTemplatesResult>;
|
|
@@ -25,12 +25,23 @@ export declare class BaseGuildMember extends DiscordBase {
|
|
|
25
25
|
ban(body?: RESTPutAPIGuildBanJSONBody, reason?: string): Promise<void>;
|
|
26
26
|
kick(reason?: string): Promise<void>;
|
|
27
27
|
edit(body: RESTPatchAPIGuildMemberJSONBody, reason?: string): Promise<GuildMember>;
|
|
28
|
+
presence(): import("..").ReturnCache<(Omit<import("discord-api-types/payloads/v10/gateway").GatewayPresenceUpdate, "user"> & {
|
|
29
|
+
id: string;
|
|
30
|
+
} & {
|
|
31
|
+
guild_id: string;
|
|
32
|
+
}) | undefined>;
|
|
33
|
+
voice(): import("..").ReturnCache<(Omit<import("discord-api-types/payloads/v10/voice").GatewayVoiceState, "member"> & {
|
|
34
|
+
guild_id: string;
|
|
35
|
+
} & {
|
|
36
|
+
guild_id: string;
|
|
37
|
+
}) | undefined>;
|
|
28
38
|
toString(): string;
|
|
29
39
|
private patch;
|
|
30
40
|
get roles(): {
|
|
31
41
|
values: readonly string[];
|
|
32
42
|
add: (id: string) => Promise<void>;
|
|
33
43
|
remove: (id: string) => Promise<void>;
|
|
44
|
+
permissions: () => Promise<PermissionsBitField>;
|
|
34
45
|
};
|
|
35
46
|
static methods({ client, guildId }: MethodContext<{
|
|
36
47
|
guildId: string;
|
|
@@ -70,6 +81,7 @@ export declare class GuildMember extends BaseGuildMember {
|
|
|
70
81
|
write(body: MessageCreateBodyRequest): Promise<import("./Message").Message>;
|
|
71
82
|
avatarURL(options?: ImageOptions): string;
|
|
72
83
|
dynamicAvatarURL(options?: ImageOptions): string;
|
|
84
|
+
fetchPermissions(): Promise<PermissionsBitField>;
|
|
73
85
|
}
|
|
74
86
|
export interface UnavailableMember {
|
|
75
87
|
pending: true;
|
|
@@ -33,6 +33,12 @@ class BaseGuildMember extends DiscordBase_1.DiscordBase {
|
|
|
33
33
|
edit(body, reason) {
|
|
34
34
|
return this.client.members.edit(this.guildId, this.id, body, reason);
|
|
35
35
|
}
|
|
36
|
+
presence() {
|
|
37
|
+
return this.cache.presences?.get(this.id);
|
|
38
|
+
}
|
|
39
|
+
voice() {
|
|
40
|
+
return this.cache.voiceStates?.get(this.id, this.guildId);
|
|
41
|
+
}
|
|
36
42
|
toString() {
|
|
37
43
|
return `<@${this.id}>`;
|
|
38
44
|
}
|
|
@@ -51,6 +57,9 @@ class BaseGuildMember extends DiscordBase_1.DiscordBase {
|
|
|
51
57
|
values: Object.freeze(this._roles),
|
|
52
58
|
add: (id) => this.client.members.roles.add(this.guildId, this.id, id),
|
|
53
59
|
remove: (id) => this.client.members.roles.remove(this.guildId, this.id, id),
|
|
60
|
+
permissions: async () => new Permissions_1.PermissionsBitField(((await this.cache.roles?.bulk(this.roles.values)) ?? [])
|
|
61
|
+
.filter(x => x)
|
|
62
|
+
.map(x => BigInt(x.permissions.bits))),
|
|
54
63
|
};
|
|
55
64
|
}
|
|
56
65
|
static methods({ client, guildId }) {
|
|
@@ -116,6 +125,11 @@ class GuildMember extends BaseGuildMember {
|
|
|
116
125
|
}
|
|
117
126
|
return this.rest.cdn.guildMemberAvatar(this.guildId, this.id, this.avatar, options);
|
|
118
127
|
}
|
|
128
|
+
async fetchPermissions() {
|
|
129
|
+
if ('permissions' in this)
|
|
130
|
+
return this.permissions;
|
|
131
|
+
return this.roles.permissions();
|
|
132
|
+
}
|
|
119
133
|
}
|
|
120
134
|
exports.GuildMember = GuildMember;
|
|
121
135
|
class UnavailableMember extends BaseGuildMember {
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { BaseClient } from '../client/base';
|
|
2
2
|
import type { APIRole, MethodContext, ObjectToLower, RESTPatchAPIGuildRoleJSONBody, RESTPatchAPIGuildRolePositionsJSONBody, RESTPostAPIGuildRoleJSONBody } from '../common';
|
|
3
3
|
import { DiscordBase } from './extra/DiscordBase';
|
|
4
|
-
|
|
4
|
+
import { PermissionsBitField } from './extra/Permissions';
|
|
5
|
+
export interface GuildRole extends DiscordBase, ObjectToLower<Omit<APIRole, 'permissions'>> {
|
|
5
6
|
}
|
|
6
7
|
export declare class GuildRole extends DiscordBase {
|
|
7
8
|
readonly guildId: string;
|
|
9
|
+
permissions: PermissionsBitField;
|
|
8
10
|
constructor(client: BaseClient, data: APIRole, guildId: string);
|
|
9
|
-
guild(force?: boolean): Promise<import("./Guild").Guild<"cached"> | import("./Guild").Guild<"api"
|
|
11
|
+
guild(force?: boolean): Promise<import("./Guild").Guild<"cached"> | import("./Guild").Guild<"api">> | undefined;
|
|
10
12
|
edit(body: RESTPatchAPIGuildRoleJSONBody, reason?: string): Promise<any>;
|
|
11
13
|
delete(reason?: string): Promise<void | undefined>;
|
|
12
14
|
static methods(ctx: MethodContext<{
|
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GuildRole = void 0;
|
|
4
4
|
const DiscordBase_1 = require("./extra/DiscordBase");
|
|
5
|
+
const Permissions_1 = require("./extra/Permissions");
|
|
5
6
|
class GuildRole extends DiscordBase_1.DiscordBase {
|
|
6
7
|
guildId;
|
|
8
|
+
permissions;
|
|
7
9
|
constructor(client, data, guildId) {
|
|
8
10
|
super(client, data);
|
|
9
11
|
this.guildId = guildId;
|
|
12
|
+
this.permissions = new Permissions_1.PermissionsBitField(BigInt(data.permissions));
|
|
10
13
|
}
|
|
11
|
-
|
|
14
|
+
guild(force = false) {
|
|
12
15
|
if (!this.guildId)
|
|
13
16
|
return;
|
|
14
17
|
return this.client.guilds.fetch(this.guildId, force);
|
|
@@ -34,6 +34,7 @@ export declare class BaseInteraction<FromGuild extends boolean = boolean, Type e
|
|
|
34
34
|
reply(body: ReplyInteractionBody): Promise<void>;
|
|
35
35
|
deferReply(flags?: MessageFlags): Promise<void>;
|
|
36
36
|
static from(client: BaseClient, gateway: GatewayInteractionCreateDispatchData, __reply?: __InternalReplyFunction): StringSelectMenuInteraction<string[]> | AutocompleteInteraction<boolean> | BaseInteraction<boolean, import("discord-api-types/payloads/v10/_interactions/ping").APIPingInteraction>;
|
|
37
|
+
fetchGuild(force?: boolean): Promise<import("./Guild").Guild<"cached"> | import("./Guild").Guild<"api">> | undefined;
|
|
37
38
|
}
|
|
38
39
|
export type AllInteractions = AutocompleteInteraction | ChatInputCommandInteraction | UserCommandInteraction | MessageCommandInteraction | ComponentInteraction | SelectMenuInteraction | ModalSubmitInteraction | BaseInteraction;
|
|
39
40
|
export interface AutocompleteInteraction extends ObjectToLower<Omit<APIApplicationCommandAutocompleteInteraction, 'user' | 'member' | 'type' | 'data' | 'message' | 'channel' | 'app_permissions'>> {
|
|
@@ -72,6 +73,7 @@ export declare class ComponentInteraction<FromGuild extends boolean = boolean, T
|
|
|
72
73
|
channelId: string;
|
|
73
74
|
channel: AllChannels;
|
|
74
75
|
type: InteractionType.MessageComponent;
|
|
76
|
+
message: Message;
|
|
75
77
|
update(data: ComponentInteractionMessageUpdate): Promise<void>;
|
|
76
78
|
deferUpdate(): Promise<void>;
|
|
77
79
|
get customId(): string;
|
|
@@ -14,7 +14,6 @@ const ts_mixer_1 = require("ts-mixer");
|
|
|
14
14
|
const builders_1 = require("../builders");
|
|
15
15
|
const commands_1 = require("../commands");
|
|
16
16
|
const common_1 = require("../common");
|
|
17
|
-
const listener_1 = require("../components/listener");
|
|
18
17
|
const _1 = require("./");
|
|
19
18
|
const GuildRole_1 = require("./GuildRole");
|
|
20
19
|
const Message_1 = require("./Message");
|
|
@@ -59,12 +58,12 @@ class BaseInteraction extends DiscordBase_1.DiscordBase {
|
|
|
59
58
|
case common_1.InteractionResponseType.UpdateMessage:
|
|
60
59
|
return {
|
|
61
60
|
type: body.type,
|
|
61
|
+
// @ts-ignore
|
|
62
62
|
data: {
|
|
63
|
+
// @ts-ignore
|
|
63
64
|
...(body.data ?? {}),
|
|
64
|
-
// @ts-
|
|
65
|
-
components:
|
|
66
|
-
? body.data.components.components
|
|
67
|
-
: body.data.components)?.map(x => (x instanceof builders_1.ActionRow ? x.toJSON() : x)) ?? undefined,
|
|
65
|
+
// @ts-ignore
|
|
66
|
+
components: body.data?.components?.map(x => (x instanceof builders_1.ActionRow ? x.toJSON() : x)) ?? undefined,
|
|
68
67
|
embeds: body.data?.embeds?.map(x => (x instanceof builders_1.Embed ? x.toJSON() : x)) ?? undefined,
|
|
69
68
|
attachments: body.data?.attachments?.map((x, i) => ({ id: i, ...(0, builders_1.resolveAttachment)(x) })) ?? undefined,
|
|
70
69
|
},
|
|
@@ -90,7 +89,7 @@ class BaseInteraction extends DiscordBase_1.DiscordBase {
|
|
|
90
89
|
static transformBody(body) {
|
|
91
90
|
return {
|
|
92
91
|
...body,
|
|
93
|
-
components:
|
|
92
|
+
components: body.components?.map(x => (x instanceof builders_1.ActionRow ? x.toJSON() : x)) ?? undefined,
|
|
94
93
|
embeds: body?.embeds?.map(x => (x instanceof builders_1.Embed ? x.toJSON() : x)) ?? undefined,
|
|
95
94
|
// attachments: body.attachments?.map((x, i) => ({ id: i, ...resolveAttachment(x) })) ?? undefined,
|
|
96
95
|
};
|
|
@@ -115,11 +114,10 @@ class BaseInteraction extends DiscordBase_1.DiscordBase {
|
|
|
115
114
|
}
|
|
116
115
|
else
|
|
117
116
|
this.matchReplied(body.data, body.type);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
: this.id, body);
|
|
117
|
+
// @ts-expect-error
|
|
118
|
+
if (body.data instanceof builders_1.Modal)
|
|
119
|
+
// @ts-expect-error
|
|
120
|
+
this.client.components.modals.set(this.user.id, body.data.__exec);
|
|
123
121
|
await this.replied;
|
|
124
122
|
}
|
|
125
123
|
deferReply(flags) {
|
|
@@ -166,6 +164,9 @@ class BaseInteraction extends DiscordBase_1.DiscordBase {
|
|
|
166
164
|
return new BaseInteraction(client, gateway);
|
|
167
165
|
}
|
|
168
166
|
}
|
|
167
|
+
fetchGuild(force = false) {
|
|
168
|
+
return this.guildId ? this.client.guilds.fetch(this.guildId, force) : undefined;
|
|
169
|
+
}
|
|
169
170
|
}
|
|
170
171
|
exports.BaseInteraction = BaseInteraction;
|
|
171
172
|
class AutocompleteInteraction extends BaseInteraction {
|
|
@@ -226,7 +227,6 @@ class Interaction extends BaseInteraction {
|
|
|
226
227
|
body: BaseInteraction.transformBody(data),
|
|
227
228
|
files: files ? await (0, builders_1.resolveFiles)(files) : undefined,
|
|
228
229
|
});
|
|
229
|
-
this.client.components.onRequestInteractionUpdate(body, apiMessage);
|
|
230
230
|
return new Message_1.Message(this.client, apiMessage);
|
|
231
231
|
}
|
|
232
232
|
editResponse(body) {
|
|
@@ -250,7 +250,6 @@ class Interaction extends BaseInteraction {
|
|
|
250
250
|
body: BaseInteraction.transformBody(body),
|
|
251
251
|
files: files,
|
|
252
252
|
});
|
|
253
|
-
this.client.components.onRequestMessage(body, apiMessage);
|
|
254
253
|
return new Message_1.Message(this.client, apiMessage);
|
|
255
254
|
}
|
|
256
255
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ListenerOptions } from '../builders';
|
|
1
2
|
import type { BaseClient } from '../client/base';
|
|
2
3
|
import type { APIChannelMention, APIMessage, GatewayMessageCreateDispatchData, ObjectToLower } from '../common';
|
|
3
4
|
import type { EmojiResolvable } from '../common/types/resolvables';
|
|
@@ -23,8 +24,12 @@ export declare class BaseMessage extends DiscordBase {
|
|
|
23
24
|
users: (GuildMember | User)[];
|
|
24
25
|
};
|
|
25
26
|
constructor(client: BaseClient, data: MessageData);
|
|
27
|
+
createComponentCollector(options?: ListenerOptions): {
|
|
28
|
+
run: (customId: string, callback: import("../builders").ComponentCallback) => any;
|
|
29
|
+
stop: (reason?: string | undefined) => void;
|
|
30
|
+
};
|
|
26
31
|
get url(): string;
|
|
27
|
-
guild(force?: boolean): Promise<import("./Guild").Guild<"cached"> | import("./Guild").Guild<"api"
|
|
32
|
+
guild(force?: boolean): Promise<import("./Guild").Guild<"cached"> | import("./Guild").Guild<"api">> | undefined;
|
|
28
33
|
channel(force?: boolean): Promise<import("./channels").AllChannels>;
|
|
29
34
|
react(emoji: EmojiResolvable): Promise<never>;
|
|
30
35
|
private patch;
|
|
@@ -34,7 +39,7 @@ export interface Message extends BaseMessage, ObjectToLower<Omit<MessageData, 't
|
|
|
34
39
|
export declare class Message extends BaseMessage {
|
|
35
40
|
constructor(client: BaseClient, data: MessageData);
|
|
36
41
|
fetch(): Promise<Message>;
|
|
37
|
-
reply(body: Omit<MessageCreateBodyRequest, 'message_reference'
|
|
42
|
+
reply(body: Omit<MessageCreateBodyRequest, 'message_reference'>, fail?: boolean): Promise<Message>;
|
|
38
43
|
edit(body: MessageUpdateBodyRequest): Promise<Message>;
|
|
39
44
|
write(body: MessageCreateBodyRequest): Promise<Message>;
|
|
40
45
|
delete(reason?: string): Promise<void>;
|
|
@@ -23,10 +23,13 @@ class BaseMessage extends DiscordBase_1.DiscordBase {
|
|
|
23
23
|
this.components = data.components?.map(x => new ActionRow_1.MessageActionRowComponent(x)) ?? [];
|
|
24
24
|
this.patch(data);
|
|
25
25
|
}
|
|
26
|
+
createComponentCollector(options) {
|
|
27
|
+
return this.client.components.createComponentCollector(this.id, options);
|
|
28
|
+
}
|
|
26
29
|
get url() {
|
|
27
30
|
return (0, functions_1.messageLink)(this.channelId, this.id, this.guildId);
|
|
28
31
|
}
|
|
29
|
-
|
|
32
|
+
guild(force = false) {
|
|
30
33
|
if (!this.guildId)
|
|
31
34
|
return;
|
|
32
35
|
return this.client.guilds.fetch(this.guildId, force);
|
|
@@ -74,14 +77,14 @@ class Message extends BaseMessage {
|
|
|
74
77
|
fetch() {
|
|
75
78
|
return this.client.messages.fetch(this.id, this.channelId);
|
|
76
79
|
}
|
|
77
|
-
reply(body) {
|
|
80
|
+
reply(body, fail = true) {
|
|
78
81
|
return this.write({
|
|
79
82
|
...body,
|
|
80
83
|
message_reference: {
|
|
81
84
|
message_id: this.id,
|
|
82
85
|
channel_id: this.channelId,
|
|
83
86
|
guild_id: this.guildId,
|
|
84
|
-
fail_if_not_exists:
|
|
87
|
+
fail_if_not_exists: fail,
|
|
85
88
|
},
|
|
86
89
|
});
|
|
87
90
|
}
|
|
@@ -8,7 +8,7 @@ export interface Sticker extends DiscordBase, ObjectToLower<Omit<APISticker, 'us
|
|
|
8
8
|
export declare class Sticker extends DiscordBase {
|
|
9
9
|
user?: User;
|
|
10
10
|
constructor(client: BaseClient, data: APISticker);
|
|
11
|
-
guild(force?: boolean): Promise<import("./Guild").Guild<"cached"> | import("./Guild").Guild<"api"
|
|
11
|
+
guild(force?: boolean): Promise<import("./Guild").Guild<"cached"> | import("./Guild").Guild<"api">> | undefined;
|
|
12
12
|
edit(body: RESTPatchAPIGuildStickerJSONBody, reason?: string): Promise<Sticker> | undefined;
|
|
13
13
|
fetch(force?: boolean): Promise<Sticker> | undefined;
|
|
14
14
|
delete(reason?: string): Promise<void> | undefined;
|
package/lib/structures/User.d.ts
CHANGED
|
@@ -16,5 +16,10 @@ export declare class User extends DiscordBase<APIUser> {
|
|
|
16
16
|
dm(force?: boolean): Promise<import("./channels").DMChannel>;
|
|
17
17
|
write(body: MessageCreateBodyRequest): Promise<import("./Message").Message>;
|
|
18
18
|
avatarURL(options?: ImageOptions): string;
|
|
19
|
+
presence(): import("..").ReturnCache<(Omit<import("discord-api-types/payloads/v10/gateway").GatewayPresenceUpdate, "user"> & {
|
|
20
|
+
id: string;
|
|
21
|
+
} & {
|
|
22
|
+
guild_id: string;
|
|
23
|
+
}) | undefined>;
|
|
19
24
|
toString(): string;
|
|
20
25
|
}
|
package/lib/structures/User.js
CHANGED
|
@@ -10,7 +10,7 @@ export declare class Webhook extends DiscordBase {
|
|
|
10
10
|
sourceGuild?: Partial<AnonymousGuild>;
|
|
11
11
|
messages: ReturnType<typeof Webhook.messages>;
|
|
12
12
|
constructor(client: BaseClient, data: APIWebhook);
|
|
13
|
-
guild(force?: boolean): Promise<import("./Guild").Guild<"cached"> | import("./Guild").Guild<"api"
|
|
13
|
+
guild(force?: boolean): Promise<import("./Guild").Guild<"cached"> | import("./Guild").Guild<"api">> | undefined;
|
|
14
14
|
channel(force?: boolean): Promise<import("./channels").BaseChannel<import("discord-api-types/payloads/v10/channel").ChannelType> | import("./channels").DMChannel | import("./channels").CategoryChannel | undefined>;
|
|
15
15
|
avatarURL(options?: ImageOptions): string | null;
|
|
16
16
|
fetch(): Promise<Webhook>;
|
|
@@ -20,7 +20,7 @@ class Webhook extends DiscordBase_1.DiscordBase {
|
|
|
20
20
|
messages: Webhook.messages({ client, webhookId: this.id, webhookToken: this.token }),
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
guild(force = false) {
|
|
24
24
|
if (!this.sourceGuild?.id)
|
|
25
25
|
return;
|
|
26
26
|
return this.client.guilds.fetch(this.sourceGuild.id, force);
|