seyfert 1.2.1 → 1.2.3

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.
Files changed (89) hide show
  1. package/LICENSE +190 -190
  2. package/README.md +46 -46
  3. package/lib/api/Router.d.ts +9 -0
  4. package/lib/api/Router.js +16 -8
  5. package/lib/api/Routes/cdn.d.ts +26 -15
  6. package/lib/api/api.d.ts +2 -3
  7. package/lib/api/api.js +4 -9
  8. package/lib/api/index.d.ts +0 -1
  9. package/lib/api/index.js +0 -1
  10. package/lib/builders/Modal.d.ts +4 -1
  11. package/lib/builders/Modal.js +4 -1
  12. package/lib/cache/adapters/default.d.ts +1 -0
  13. package/lib/cache/adapters/default.js +4 -0
  14. package/lib/cache/adapters/redis.d.ts +2 -0
  15. package/lib/cache/adapters/redis.js +17 -0
  16. package/lib/cache/adapters/types.d.ts +1 -0
  17. package/lib/cache/adapters/workeradapter.d.ts +1 -0
  18. package/lib/cache/adapters/workeradapter.js +6 -9
  19. package/lib/cache/index.d.ts +4 -6
  20. package/lib/cache/index.js +3 -0
  21. package/lib/cache/resources/overwrites.d.ts +2 -0
  22. package/lib/cache/resources/voice-states.d.ts +7 -2
  23. package/lib/cache/resources/voice-states.js +11 -0
  24. package/lib/client/base.d.ts +1 -1
  25. package/lib/client/base.js +8 -5
  26. package/lib/client/oninteractioncreate.js +7 -7
  27. package/lib/client/onmessagecreate.js +27 -15
  28. package/lib/client/workerclient.js +6 -12
  29. package/lib/commands/applications/chat.d.ts +20 -15
  30. package/lib/commands/applications/chat.js +13 -7
  31. package/lib/commands/applications/chatcontext.d.ts +2 -1
  32. package/lib/commands/applications/chatcontext.js +3 -0
  33. package/lib/commands/applications/menu.d.ts +4 -3
  34. package/lib/commands/applications/menu.js +9 -6
  35. package/lib/commands/applications/menucontext.d.ts +4 -1
  36. package/lib/commands/applications/menucontext.js +9 -0
  37. package/lib/commands/applications/shared.d.ts +4 -0
  38. package/lib/commands/applications/shared.js +6 -0
  39. package/lib/commands/basecontex.d.ts +1 -1
  40. package/lib/commands/basecontex.js +5 -11
  41. package/lib/commands/decorators.d.ts +14 -4
  42. package/lib/commands/decorators.js +29 -5
  43. package/lib/commands/handler.js +2 -0
  44. package/lib/common/shorters/channels.d.ts +12 -2
  45. package/lib/common/shorters/channels.js +16 -2
  46. package/lib/common/shorters/members.d.ts +6 -0
  47. package/lib/common/shorters/members.js +6 -0
  48. package/lib/common/shorters/messages.d.ts +2 -2
  49. package/lib/common/shorters/messages.js +7 -3
  50. package/lib/common/types/options.d.ts +2 -2
  51. package/lib/components/componentcontext.d.ts +1 -0
  52. package/lib/components/componentcontext.js +3 -0
  53. package/lib/structures/GuildEmoji.d.ts +2 -2
  54. package/lib/structures/GuildEmoji.js +1 -1
  55. package/lib/structures/GuildMember.d.ts +1 -5
  56. package/lib/structures/GuildMember.js +3 -3
  57. package/lib/structures/Message.d.ts +1 -1
  58. package/lib/structures/User.d.ts +2 -3
  59. package/lib/structures/User.js +9 -4
  60. package/lib/structures/VoiceState.d.ts +18 -0
  61. package/lib/structures/VoiceState.js +48 -0
  62. package/lib/structures/Webhook.js +1 -1
  63. package/lib/structures/channels.d.ts +11 -3
  64. package/lib/structures/channels.js +14 -1
  65. package/lib/structures/extra/BaseGuild.js +3 -3
  66. package/lib/structures/extra/Permissions.d.ts +1 -1
  67. package/lib/structures/index.d.ts +1 -0
  68. package/lib/structures/index.js +1 -0
  69. package/lib/websocket/discord/shard.d.ts +4 -4
  70. package/lib/websocket/discord/shard.js +12 -17
  71. package/lib/websocket/discord/sharder.d.ts +1 -1
  72. package/lib/websocket/discord/sharder.js +2 -2
  73. package/lib/websocket/discord/worker.d.ts +1 -1
  74. package/lib/websocket/discord/workermanager.js +4 -10
  75. package/lib/websocket/structures/index.d.ts +6 -99
  76. package/lib/websocket/structures/index.js +29 -211
  77. package/lib/websocket/structures/timeout.d.ts +2 -2
  78. package/lib/websocket/structures/timeout.js +13 -16
  79. package/package.json +2 -2
  80. package/lib/api/CDN.d.ts +0 -212
  81. package/lib/api/CDN.js +0 -228
  82. package/lib/common/shorters/overwrites.d.ts +0 -29
  83. package/lib/common/shorters/overwrites.js +0 -63
  84. package/lib/components/listener.d.ts +0 -11
  85. package/lib/components/listener.js +0 -17
  86. package/lib/structures/extra/BaseComponent.d.ts +0 -9
  87. package/lib/structures/extra/BaseComponent.js +0 -12
  88. package/lib/structures/extra/BaseSelectMenuComponent.d.ts +0 -9
  89. package/lib/structures/extra/BaseSelectMenuComponent.js +0 -13
package/lib/api/CDN.js DELETED
@@ -1,228 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CDN = void 0;
4
- /* eslint-disable jsdoc/check-param-names */
5
- const index_js_1 = require("../common/index.js");
6
- const constants_js_1 = require("./utils/constants.js");
7
- /**
8
- * The CDN link builder
9
- */
10
- class CDN {
11
- base;
12
- constructor(base = index_js_1.CDN_URL) {
13
- this.base = base;
14
- }
15
- /**
16
- * Generates an app asset URL for a client's asset.
17
- *
18
- * @param clientId - The client id that has the asset
19
- * @param assetHash - The hash provided by Discord for this asset
20
- * @param options - Optional options for the asset
21
- */
22
- appAsset(clientId, assetHash, options) {
23
- return this.makeURL(`/app-assets/${clientId}/${assetHash}`, options);
24
- }
25
- /**
26
- * Generates an app icon URL for a client's icon.
27
- *
28
- * @param clientId - The client id that has the icon
29
- * @param iconHash - The hash provided by Discord for this icon
30
- * @param options - Optional options for the icon
31
- */
32
- appIcon(clientId, iconHash, options) {
33
- return this.makeURL(`/app-icons/${clientId}/${iconHash}`, options);
34
- }
35
- /**
36
- * Generates an avatar URL, e.g. for a user or a webhook.
37
- *
38
- * @param id - The id that has the icon
39
- * @param avatarHash - The hash provided by Discord for this avatar
40
- * @param options - Optional options for the avatar
41
- */
42
- avatar(id, avatarHash, options) {
43
- return this.dynamicMakeURL(`/avatars/${id}/${avatarHash}`, avatarHash, options);
44
- }
45
- /**
46
- * Generates a user avatar decoration URL.
47
- *
48
- * @param userId - The id of the user
49
- * @param userAvatarDecoration - The hash provided by Discord for this avatar decoration
50
- * @param options - Optional options for the avatar decoration
51
- */
52
- avatarDecoration(userId, userAvatarDecoration, options) {
53
- return this.makeURL(`/avatar-decorations/${userId}/${userAvatarDecoration}`, options);
54
- }
55
- /**
56
- * Generates a banner URL, e.g. for a user or a guild.
57
- *
58
- * @param id - The id that has the banner splash
59
- * @param bannerHash - The hash provided by Discord for this banner
60
- * @param options - Optional options for the banner
61
- */
62
- banner(id, bannerHash, options) {
63
- return this.dynamicMakeURL(`/banners/${id}/${bannerHash}`, bannerHash, options);
64
- }
65
- /**
66
- * Generates an icon URL for a channel, e.g. a group DM.
67
- *
68
- * @param channelId - The channel id that has the icon
69
- * @param iconHash - The hash provided by Discord for this channel
70
- * @param options - Optional options for the icon
71
- */
72
- channelIcon(channelId, iconHash, options) {
73
- return this.makeURL(`/channel-icons/${channelId}/${iconHash}`, options);
74
- }
75
- /**
76
- * Generates a default avatar URL
77
- *
78
- * @param index - The default avatar index
79
- * @remarks
80
- * To calculate the index for a user do `(userId >> 22) % 6`,
81
- * or `discriminator % 5` if they're using the legacy username system.
82
- */
83
- defaultAvatar(index) {
84
- return this.makeURL(`/embed/avatars/${index}`, { extension: 'png' });
85
- }
86
- /**
87
- * Generates a discovery splash URL for a guild's discovery splash.
88
- *
89
- * @param guildId - The guild id that has the discovery splash
90
- * @param splashHash - The hash provided by Discord for this splash
91
- * @param options - Optional options for the splash
92
- */
93
- discoverySplash(guildId, splashHash, options) {
94
- return this.makeURL(`/discovery-splashes/${guildId}/${splashHash}`, options);
95
- }
96
- /**
97
- * Generates an emoji's URL for an emoji.
98
- *
99
- * @param emojiId - The emoji id
100
- * @param options - Optional options for the emoji
101
- */
102
- emoji(emojiId, options) {
103
- const resolvedOptions = options;
104
- return this.makeURL(`/emojis/${emojiId}`, resolvedOptions);
105
- }
106
- /**
107
- * Generates a guild member avatar URL.
108
- *
109
- * @param guildId - The id of the guild
110
- * @param userId - The id of the user
111
- * @param avatarHash - The hash provided by Discord for this avatar
112
- * @param options - Optional options for the avatar
113
- */
114
- guildMemberAvatar(guildId, userId, avatarHash, options) {
115
- return this.dynamicMakeURL(`/guilds/${guildId}/users/${userId}/avatars/${avatarHash}`, avatarHash, options);
116
- }
117
- /**
118
- * Generates a guild member banner URL.
119
- *
120
- * @param guildId - The id of the guild
121
- * @param userId - The id of the user
122
- * @param bannerHash - The hash provided by Discord for this banner
123
- * @param options - Optional options for the banner
124
- */
125
- guildMemberBanner(guildId, userId, bannerHash, options) {
126
- return this.dynamicMakeURL(`/guilds/${guildId}/users/${userId}/banner`, bannerHash, options);
127
- }
128
- /**
129
- * Generates an icon URL, e.g. for a guild.
130
- *
131
- * @param id - The id that has the icon splash
132
- * @param iconHash - The hash provided by Discord for this icon
133
- * @param options - Optional options for the icon
134
- */
135
- icon(id, iconHash, options) {
136
- return this.dynamicMakeURL(`/icons/${id}/${iconHash}`, iconHash, options);
137
- }
138
- /**
139
- * Generates a URL for the icon of a role
140
- *
141
- * @param roleId - The id of the role that has the icon
142
- * @param roleIconHash - The hash provided by Discord for this role icon
143
- * @param options - Optional options for the role icon
144
- */
145
- roleIcon(roleId, roleIconHash, options) {
146
- return this.makeURL(`/role-icons/${roleId}/${roleIconHash}`, options);
147
- }
148
- /**
149
- * Generates a guild invite splash URL for a guild's invite splash.
150
- *
151
- * @param guildId - The guild id that has the invite splash
152
- * @param splashHash - The hash provided by Discord for this splash
153
- * @param options - Optional options for the splash
154
- */
155
- splash(guildId, splashHash, options) {
156
- return this.makeURL(`/splashes/${guildId}/${splashHash}`, options);
157
- }
158
- /**
159
- * Generates a sticker URL.
160
- *
161
- * @param stickerId - The sticker id
162
- * @param extension - The extension of the sticker
163
- * @privateRemarks
164
- * Stickers cannot have a `.webp` extension, so we default to a `.png`
165
- */
166
- sticker(stickerId, extension = 'png') {
167
- return this.makeURL(`/stickers/${stickerId}`, { allowedExtensions: constants_js_1.ALLOWED_STICKER_EXTENSIONS, extension });
168
- }
169
- /**
170
- * Generates a sticker pack banner URL.
171
- *
172
- * @param bannerId - The banner id
173
- * @param options - Optional options for the banner
174
- */
175
- stickerPackBanner(bannerId, options) {
176
- return this.makeURL(`/app-assets/710982414301790216/store/${bannerId}`, options);
177
- }
178
- /**
179
- * Generates a team icon URL for a team's icon.
180
- *
181
- * @param teamId - The team id that has the icon
182
- * @param iconHash - The hash provided by Discord for this icon
183
- * @param options - Optional options for the icon
184
- */
185
- teamIcon(teamId, iconHash, options) {
186
- return this.makeURL(`/team-icons/${teamId}/${iconHash}`, options);
187
- }
188
- /**
189
- * Generates a cover image for a guild scheduled event.
190
- *
191
- * @param scheduledEventId - The scheduled event id
192
- * @param coverHash - The hash provided by discord for this cover image
193
- * @param options - Optional options for the cover image
194
- */
195
- guildScheduledEventCover(scheduledEventId, coverHash, options) {
196
- return this.makeURL(`/guild-events/${scheduledEventId}/${coverHash}`, options);
197
- }
198
- /**
199
- * Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
200
- *
201
- * @param route - The base cdn route
202
- * @param hash - The hash provided by Discord for this icon
203
- * @param options - Optional options for the link
204
- */
205
- dynamicMakeURL(route, hash, { forceStatic = false, ...options } = {}) {
206
- return this.makeURL(route, !forceStatic && hash.startsWith('a_') ? { ...options, extension: 'gif' } : options);
207
- }
208
- /**
209
- * Constructs the URL for the resource
210
- *
211
- * @param route - The base cdn route
212
- * @param options - The extension/size options for the link
213
- */
214
- makeURL(route, { allowedExtensions = constants_js_1.ALLOWED_EXTENSIONS, extension = 'webp', size } = {}) {
215
- if (!allowedExtensions.includes(extension)) {
216
- throw new RangeError(`Invalid extension provided: ${extension}\nMust be one of: ${allowedExtensions.join(', ')}`);
217
- }
218
- if (size && !constants_js_1.ALLOWED_SIZES.includes(size)) {
219
- throw new RangeError(`Invalid size provided: ${size}\nMust be one of: ${constants_js_1.ALLOWED_SIZES.join(', ')}`);
220
- }
221
- const url = new URL(`${this.base}${route}.${extension}`);
222
- if (size) {
223
- url.searchParams.set('size', String(size));
224
- }
225
- return url.toString();
226
- }
227
- }
228
- exports.CDN = CDN;
@@ -1,29 +0,0 @@
1
- import type { GuildMember, GuildRole } from '../../structures';
2
- import { PermissionsBitField } from '../../structures/extra/Permissions';
3
- import { BaseShorter } from './base';
4
- export declare class OverwritesShorter extends BaseShorter {
5
- get overwrites(): {
6
- memberPermissions: (channelId: string, member: GuildMember, checkAdmin?: boolean) => Promise<PermissionsBitField>;
7
- overwritesFor: (channelId: string, member: GuildMember) => Promise<{
8
- everyone: {
9
- type: number;
10
- id: string;
11
- deny: PermissionsBitField;
12
- allow: PermissionsBitField;
13
- } | undefined;
14
- roles: {
15
- type: number;
16
- id: string;
17
- deny: PermissionsBitField;
18
- allow: PermissionsBitField;
19
- }[];
20
- member: {
21
- type: number;
22
- id: string;
23
- deny: PermissionsBitField;
24
- allow: PermissionsBitField;
25
- } | undefined;
26
- }>;
27
- rolePermissions: (channelId: string, role: GuildRole, checkAdmin?: boolean) => Promise<PermissionsBitField>;
28
- };
29
- }
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OverwritesShorter = void 0;
4
- const v10_1 = require("discord-api-types/v10");
5
- const Permissions_1 = require("../../structures/extra/Permissions");
6
- const base_1 = require("./base");
7
- class OverwritesShorter extends base_1.BaseShorter {
8
- get overwrites() {
9
- return {
10
- memberPermissions: async (channelId, member, checkAdmin = true) => {
11
- const permissions = await member.fetchPermissions();
12
- if (checkAdmin && permissions.has(v10_1.PermissionFlagsBits.Administrator)) {
13
- return new Permissions_1.PermissionsBitField(Permissions_1.PermissionsBitField.All);
14
- }
15
- const overwrites = await this.overwrites.overwritesFor(channelId, member);
16
- permissions.remove(overwrites.everyone?.deny.bits ?? 0n);
17
- permissions.add(overwrites.everyone?.allow.bits ?? 0n);
18
- permissions.remove(overwrites.roles.length > 0 ? overwrites.roles.map(role => role.deny.bits) : 0n);
19
- permissions.add(overwrites.roles.length > 0 ? overwrites.roles.map(role => role.allow.bits) : 0n);
20
- permissions.remove(overwrites.member?.deny.bits ?? 0n);
21
- permissions.add(overwrites.member?.allow.bits ?? 0n);
22
- return permissions;
23
- },
24
- overwritesFor: async (channelId, member) => {
25
- const roleOverwrites = [];
26
- let memberOverwrites;
27
- let everyoneOverwrites;
28
- const channelOverwrites = await this.client.cache.overwrites?.get(channelId) ?? [];
29
- for (const overwrite of channelOverwrites) {
30
- if (overwrite.id === member.guildId) {
31
- everyoneOverwrites = overwrite;
32
- }
33
- else if (member.roles.values.includes(overwrite.id)) {
34
- roleOverwrites.push(overwrite);
35
- }
36
- else if (overwrite.id === member.id) {
37
- memberOverwrites = overwrite;
38
- }
39
- }
40
- return {
41
- everyone: everyoneOverwrites,
42
- roles: roleOverwrites,
43
- member: memberOverwrites,
44
- };
45
- },
46
- rolePermissions: async (channelId, role, checkAdmin = true) => {
47
- if (checkAdmin && role.permissions.has(v10_1.PermissionFlagsBits.Administrator)) {
48
- return new Permissions_1.PermissionsBitField(Permissions_1.PermissionsBitField.All);
49
- }
50
- const channelOverwrites = await this.client.cache.overwrites?.get(channelId) ?? [];
51
- const everyoneOverwrites = channelOverwrites.find(x => x.id === role.guildId);
52
- const roleOverwrites = channelOverwrites.find(x => x.id === role.id);
53
- const permissions = new Permissions_1.PermissionsBitField(role.permissions.bits);
54
- permissions.remove(everyoneOverwrites?.deny.bits ?? 0n);
55
- permissions.add(everyoneOverwrites?.allow.bits ?? 0n);
56
- permissions.remove(roleOverwrites?.deny.bits ?? 0n);
57
- permissions.add(roleOverwrites?.allow.bits ?? 0n);
58
- return permissions;
59
- },
60
- };
61
- }
62
- }
63
- exports.OverwritesShorter = OverwritesShorter;
@@ -1,11 +0,0 @@
1
- /// <reference types="node" />
2
- import type { ActionRow, BuilderComponents, ListenerOptions } from '../builders';
3
- import type { RestOrArray } from '../common';
4
- export declare class ComponentsListener<T extends BuilderComponents> {
5
- readonly options: ListenerOptions;
6
- components: ActionRow<T>[];
7
- idle?: NodeJS.Timeout;
8
- timeout?: NodeJS.Timeout;
9
- constructor(options?: ListenerOptions);
10
- addRows(...row: RestOrArray<ActionRow<T>>): this;
11
- }
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ComponentsListener = void 0;
4
- class ComponentsListener {
5
- options;
6
- components = [];
7
- idle;
8
- timeout;
9
- constructor(options = {}) {
10
- this.options = options;
11
- }
12
- addRows(...row) {
13
- this.components = this.components.concat(row.flat());
14
- return this;
15
- }
16
- }
17
- exports.ComponentsListener = ComponentsListener;
@@ -1,9 +0,0 @@
1
- import type { APIBaseComponent, ComponentType } from '../../common';
2
- export interface BaseComponent<T extends ComponentType> extends APIBaseComponent<T> {
3
- }
4
- export declare class BaseComponent<T extends ComponentType> {
5
- constructor(data: APIBaseComponent<T>);
6
- toJSON(): {
7
- type: T;
8
- };
9
- }
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseComponent = void 0;
4
- class BaseComponent {
5
- constructor(data) {
6
- Object.assign(this, data);
7
- }
8
- toJSON() {
9
- return { type: this.type };
10
- }
11
- }
12
- exports.BaseComponent = BaseComponent;
@@ -1,9 +0,0 @@
1
- import type { APIBaseSelectMenuComponent, ComponentType, Identify, ObjectToLower } from '../../common';
2
- import { BaseComponent } from './BaseComponent';
3
- export type APISelectMenuComponentTypes = ComponentType.ChannelSelect | ComponentType.MentionableSelect | ComponentType.RoleSelect | ComponentType.StringSelect | ComponentType.UserSelect;
4
- export interface BaseSelectMenuComponent<T extends APISelectMenuComponentTypes> extends BaseComponent<T>, ObjectToLower<Identify<Omit<APIBaseSelectMenuComponent<APISelectMenuComponentTypes>, 'type'>>> {
5
- }
6
- export declare class BaseSelectMenuComponent<T extends APISelectMenuComponentTypes> extends BaseComponent<T> {
7
- constructor(data: APIBaseSelectMenuComponent<T>);
8
- toJSON(): this;
9
- }
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseSelectMenuComponent = void 0;
4
- const BaseComponent_1 = require("./BaseComponent");
5
- class BaseSelectMenuComponent extends BaseComponent_1.BaseComponent {
6
- constructor(data) {
7
- super(data);
8
- }
9
- toJSON() {
10
- return { ...this };
11
- }
12
- }
13
- exports.BaseSelectMenuComponent = BaseSelectMenuComponent;