seyfert 1.2.2 → 1.3.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.
Files changed (162) 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/Routes/channels.d.ts +15 -1
  7. package/lib/api/api.d.ts +2 -3
  8. package/lib/api/api.js +4 -9
  9. package/lib/api/index.d.ts +0 -1
  10. package/lib/api/index.js +0 -1
  11. package/lib/api/utils/utils.d.ts +1 -1
  12. package/lib/api/utils/utils.js +2 -2
  13. package/lib/builders/Modal.d.ts +4 -1
  14. package/lib/builders/Modal.js +4 -1
  15. package/lib/builders/Poll.d.ts +16 -0
  16. package/lib/builders/Poll.js +48 -0
  17. package/lib/builders/index.d.ts +1 -0
  18. package/lib/builders/index.js +1 -0
  19. package/lib/cache/adapters/default.d.ts +1 -0
  20. package/lib/cache/adapters/default.js +4 -0
  21. package/lib/cache/adapters/index.d.ts +1 -0
  22. package/lib/cache/adapters/index.js +1 -0
  23. package/lib/cache/adapters/limited.d.ts +50 -0
  24. package/lib/cache/adapters/limited.js +188 -0
  25. package/lib/cache/adapters/redis.d.ts +2 -0
  26. package/lib/cache/adapters/redis.js +17 -0
  27. package/lib/cache/adapters/types.d.ts +1 -0
  28. package/lib/cache/adapters/workeradapter.d.ts +1 -0
  29. package/lib/cache/adapters/workeradapter.js +6 -9
  30. package/lib/cache/index.d.ts +8 -3
  31. package/lib/cache/index.js +41 -7
  32. package/lib/cache/resources/channels.d.ts +2 -1
  33. package/lib/cache/resources/default/base.d.ts +3 -3
  34. package/lib/cache/resources/default/base.js +8 -3
  35. package/lib/cache/resources/default/guild-based.d.ts +2 -1
  36. package/lib/cache/resources/default/guild-based.js +7 -3
  37. package/lib/cache/resources/default/guild-related.d.ts +2 -1
  38. package/lib/cache/resources/default/guild-related.js +7 -3
  39. package/lib/cache/resources/emojis.d.ts +2 -0
  40. package/lib/cache/resources/emojis.js +4 -0
  41. package/lib/cache/resources/guilds.d.ts +2 -0
  42. package/lib/cache/resources/guilds.js +4 -0
  43. package/lib/cache/resources/members.d.ts +2 -0
  44. package/lib/cache/resources/members.js +5 -1
  45. package/lib/cache/resources/messages.d.ts +15 -0
  46. package/lib/cache/resources/messages.js +53 -0
  47. package/lib/cache/resources/overwrites.d.ts +4 -0
  48. package/lib/cache/resources/overwrites.js +4 -0
  49. package/lib/cache/resources/presence.d.ts +1 -0
  50. package/lib/cache/resources/presence.js +4 -0
  51. package/lib/cache/resources/roles.d.ts +2 -0
  52. package/lib/cache/resources/roles.js +4 -0
  53. package/lib/cache/resources/stage-instances.d.ts +1 -0
  54. package/lib/cache/resources/stage-instances.js +5 -1
  55. package/lib/cache/resources/stickers.d.ts +2 -0
  56. package/lib/cache/resources/stickers.js +4 -0
  57. package/lib/cache/resources/threads.d.ts +2 -0
  58. package/lib/cache/resources/threads.js +4 -0
  59. package/lib/cache/resources/users.d.ts +2 -0
  60. package/lib/cache/resources/users.js +4 -0
  61. package/lib/cache/resources/voice-states.d.ts +2 -1
  62. package/lib/cache/resources/voice-states.js +8 -4
  63. package/lib/client/base.d.ts +26 -14
  64. package/lib/client/base.js +41 -13
  65. package/lib/client/client.d.ts +6 -5
  66. package/lib/client/client.js +13 -1
  67. package/lib/client/oninteractioncreate.js +2 -2
  68. package/lib/client/onmessagecreate.js +17 -14
  69. package/lib/client/workerclient.d.ts +3 -3
  70. package/lib/client/workerclient.js +23 -14
  71. package/lib/collection.d.ts +8 -3
  72. package/lib/collection.js +22 -4
  73. package/lib/commands/applications/chat.d.ts +17 -20
  74. package/lib/commands/applications/chat.js +6 -21
  75. package/lib/commands/applications/chatcontext.d.ts +1 -1
  76. package/lib/commands/applications/menucontext.d.ts +1 -1
  77. package/lib/commands/applications/shared.d.ts +4 -0
  78. package/lib/commands/applications/shared.js +6 -0
  79. package/lib/commands/decorators.d.ts +11 -1
  80. package/lib/commands/decorators.js +24 -0
  81. package/lib/commands/handler.d.ts +11 -7
  82. package/lib/commands/handler.js +43 -14
  83. package/lib/common/index.d.ts +2 -0
  84. package/lib/common/index.js +2 -0
  85. package/lib/common/it/utils.d.ts +0 -1
  86. package/lib/common/it/utils.js +0 -1
  87. package/lib/common/shorters/channels.d.ts +8 -3
  88. package/lib/common/shorters/channels.js +27 -12
  89. package/lib/common/shorters/guilds.d.ts +6 -5
  90. package/lib/common/shorters/guilds.js +22 -4
  91. package/lib/common/shorters/interaction.d.ts +13 -0
  92. package/lib/common/shorters/interaction.js +61 -0
  93. package/lib/common/shorters/messages.d.ts +6 -3
  94. package/lib/common/shorters/messages.js +33 -15
  95. package/lib/common/shorters/roles.d.ts +3 -3
  96. package/lib/common/shorters/roles.js +12 -17
  97. package/lib/common/shorters/templates.d.ts +7 -6
  98. package/lib/common/shorters/templates.js +28 -6
  99. package/lib/common/shorters/threads.d.ts +39 -0
  100. package/lib/common/shorters/threads.js +76 -0
  101. package/lib/common/shorters/webhook.d.ts +1 -1
  102. package/lib/common/shorters/webhook.js +8 -2
  103. package/lib/common/types/options.d.ts +2 -2
  104. package/lib/common/types/write.d.ts +8 -5
  105. package/lib/components/ButtonComponent.js +1 -1
  106. package/lib/components/componentcontext.d.ts +1 -1
  107. package/lib/components/handler.d.ts +6 -17
  108. package/lib/components/handler.js +7 -2
  109. package/lib/events/handler.d.ts +8 -14
  110. package/lib/events/handler.js +9 -4
  111. package/lib/events/hooks/guild.d.ts +1 -1
  112. package/lib/events/hooks/guild.js +2 -2
  113. package/lib/events/hooks/message.d.ts +26 -8
  114. package/lib/events/hooks/message.js +18 -7
  115. package/lib/langs/handler.d.ts +4 -8
  116. package/lib/langs/handler.js +7 -2
  117. package/lib/structures/AutoModerationRule.d.ts +6 -6
  118. package/lib/structures/Guild.d.ts +15 -13
  119. package/lib/structures/GuildEmoji.d.ts +2 -2
  120. package/lib/structures/GuildEmoji.js +1 -1
  121. package/lib/structures/GuildMember.js +1 -1
  122. package/lib/structures/GuildRole.d.ts +5 -5
  123. package/lib/structures/GuildTemplate.d.ts +10 -10
  124. package/lib/structures/Interaction.d.ts +3 -3
  125. package/lib/structures/Interaction.js +27 -48
  126. package/lib/structures/Message.d.ts +5 -3
  127. package/lib/structures/Message.js +5 -0
  128. package/lib/structures/Poll.d.ts +15 -0
  129. package/lib/structures/Poll.js +26 -0
  130. package/lib/structures/User.d.ts +2 -3
  131. package/lib/structures/User.js +9 -4
  132. package/lib/structures/Webhook.d.ts +2 -2
  133. package/lib/structures/Webhook.js +1 -1
  134. package/lib/structures/channels.d.ts +11 -3
  135. package/lib/structures/channels.js +16 -8
  136. package/lib/structures/extra/BaseGuild.js +3 -3
  137. package/lib/structures/extra/Permissions.d.ts +1 -0
  138. package/lib/structures/index.d.ts +1 -0
  139. package/lib/structures/index.js +1 -0
  140. package/lib/websocket/SharedTypes.d.ts +7 -2
  141. package/lib/websocket/discord/worker.d.ts +1 -1
  142. package/lib/websocket/discord/workermanager.js +3 -9
  143. package/lib/websocket/structures/timeout.js +9 -12
  144. package/package.json +8 -8
  145. package/lib/api/CDN.d.ts +0 -212
  146. package/lib/api/CDN.js +0 -228
  147. package/lib/client/http/adapters/bun.d.ts +0 -14
  148. package/lib/client/http/adapters/bun.js +0 -117
  149. package/lib/client/http/adapters/index.d.ts +0 -15
  150. package/lib/client/http/adapters/index.js +0 -27
  151. package/lib/client/http/adapters/uws.d.ts +0 -17
  152. package/lib/client/http/adapters/uws.js +0 -142
  153. package/lib/client/http/httpclient.d.ts +0 -13
  154. package/lib/client/http/httpclient.js +0 -48
  155. package/lib/common/shorters/overwrites.d.ts +0 -29
  156. package/lib/common/shorters/overwrites.js +0 -63
  157. package/lib/components/listener.d.ts +0 -11
  158. package/lib/components/listener.js +0 -17
  159. package/lib/structures/extra/BaseComponent.d.ts +0 -9
  160. package/lib/structures/extra/BaseComponent.js +0 -12
  161. package/lib/structures/extra/BaseSelectMenuComponent.d.ts +0 -9
  162. package/lib/structures/extra/BaseSelectMenuComponent.js +0 -13
@@ -27,19 +27,20 @@ exports.EventHandler = void 0;
27
27
  const common_1 = require("../common");
28
28
  const RawEvents = __importStar(require("../events/hooks"));
29
29
  class EventHandler extends common_1.BaseHandler {
30
- onFail = err => this.logger.warn('<Client>.events.onFail', err);
30
+ onFail = (event, err) => this.logger.warn('<Client>.events.onFail', err, event);
31
31
  filter = (path) => path.endsWith('.js') || (!path.endsWith('.d.ts') && path.endsWith('.ts'));
32
32
  values = {};
33
33
  async load(eventsDir) {
34
34
  for (const i of await this.loadFilesK(await this.getFiles(eventsDir))) {
35
- const instance = i.file;
35
+ const instance = this.callback(i.file);
36
+ if (!instance)
37
+ continue;
36
38
  if (typeof instance?.run !== 'function') {
37
39
  this.logger.warn(i.path.split(process.cwd()).slice(1).join(process.cwd()), 'Missing run function, use `export default {...}` syntax');
38
40
  continue;
39
41
  }
40
42
  instance.__filePath = i.path;
41
43
  this.values[common_1.ReplaceRegex.snake(instance.data.name).toUpperCase()] = instance;
42
- await this.__callback?.(instance);
43
44
  }
44
45
  }
45
46
  async execute(name, ...args) {
@@ -95,7 +96,7 @@ class EventHandler extends common_1.BaseHandler {
95
96
  await Event.run(...[hook, client, shardId]);
96
97
  }
97
98
  catch (e) {
98
- await this.onFail(e);
99
+ await this.onFail(name, e);
99
100
  }
100
101
  }
101
102
  async reload(name) {
@@ -114,5 +115,9 @@ class EventHandler extends common_1.BaseHandler {
114
115
  await this.reload(common_1.ReplaceRegex.camel(i));
115
116
  }
116
117
  }
118
+ setHandlers({ callback }) {
119
+ this.callback = callback;
120
+ }
121
+ callback = (file) => file;
117
122
  }
118
123
  exports.EventHandler = EventHandler;
@@ -20,7 +20,7 @@ export declare const GUILD_BAN_REMOVE: (self: BaseClient, data: GatewayGuildBanR
20
20
  guildId: string;
21
21
  };
22
22
  export declare const GUILD_CREATE: (self: BaseClient, data: GatewayGuildCreateDispatchData) => Guild<"create">;
23
- export declare const GUILD_DELETE: (_self: BaseClient, data: GatewayGuildDeleteDispatchData) => Promise<import("discord-api-types/v10").APIUnavailableGuild>;
23
+ export declare const GUILD_DELETE: (self: BaseClient, data: GatewayGuildDeleteDispatchData) => Promise<import("discord-api-types/v10").APIUnavailableGuild | Guild<"cached">>;
24
24
  export declare const GUILD_EMOJIS_UPDATE: (self: BaseClient, data: GatewayGuildEmojisUpdateDispatchData) => {
25
25
  emojis: GuildEmoji[];
26
26
  guildId: string;
@@ -19,8 +19,8 @@ const GUILD_CREATE = (self, data) => {
19
19
  return new structures_1.Guild(self, data);
20
20
  };
21
21
  exports.GUILD_CREATE = GUILD_CREATE;
22
- const GUILD_DELETE = async (_self, data) => {
23
- return data;
22
+ const GUILD_DELETE = async (self, data) => {
23
+ return (await self.cache.guilds?.get(data.id)) ?? data;
24
24
  };
25
25
  exports.GUILD_DELETE = GUILD_DELETE;
26
26
  const GUILD_EMOJIS_UPDATE = (self, data) => {
@@ -1,18 +1,19 @@
1
- import type { GatewayMessageCreateDispatchData, GatewayMessageDeleteBulkDispatchData, GatewayMessageDeleteDispatchData, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayMessageUpdateDispatchData } from 'discord-api-types/v10';
1
+ import type { GatewayMessageCreateDispatchData, GatewayMessageDeleteBulkDispatchData, GatewayMessageDeleteDispatchData, GatewayMessagePollVoteDispatchData, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayMessageUpdateDispatchData } from 'discord-api-types/v10';
2
2
  import type { BaseClient } from '../../client/base';
3
3
  import { type MakeRequired, type PartialClass } from '../../common';
4
4
  import { Message } from '../../structures';
5
5
  export declare const MESSAGE_CREATE: (self: BaseClient, data: GatewayMessageCreateDispatchData) => Message;
6
- export declare const MESSAGE_DELETE: (_self: BaseClient, data: GatewayMessageDeleteDispatchData) => {
6
+ export declare const MESSAGE_DELETE: (self: BaseClient, data: GatewayMessageDeleteDispatchData) => Promise<{
7
7
  id: string;
8
8
  channelId: string;
9
9
  guildId?: string | undefined;
10
- };
11
- export declare const MESSAGE_DELETE_BULK: (_self: BaseClient, data: GatewayMessageDeleteBulkDispatchData) => {
10
+ }>;
11
+ export declare const MESSAGE_DELETE_BULK: (self: BaseClient, data: GatewayMessageDeleteBulkDispatchData) => Promise<{
12
+ messages: import("../..").ReturnCache<Message | undefined>[];
12
13
  ids: string[];
13
- channelId: string;
14
- guildId?: string | undefined;
15
- };
14
+ channel_id: string;
15
+ guild_id?: string | undefined;
16
+ }>;
16
17
  export declare const MESSAGE_REACTION_ADD: (_self: BaseClient, data: GatewayMessageReactionAddDispatchData) => {
17
18
  emoji: {
18
19
  roles?: string[] | undefined;
@@ -67,4 +68,21 @@ export declare const MESSAGE_REACTION_REMOVE_EMOJI: (_self: BaseClient, data: Ga
67
68
  messageId: string;
68
69
  guildId?: string | undefined;
69
70
  };
70
- export declare const MESSAGE_UPDATE: (self: BaseClient, data: GatewayMessageUpdateDispatchData) => MakeRequired<PartialClass<Message>, 'id' | 'channelId' | 'createdAt' | 'createdTimestamp' | 'rest' | 'cache' | 'api' | 'client'>;
71
+ export declare const MESSAGE_UPDATE: (self: BaseClient, data: GatewayMessageUpdateDispatchData) => Promise<[
72
+ undefined | Message,
73
+ MakeRequired<PartialClass<Message>, 'id' | 'channelId' | 'createdAt' | 'createdTimestamp' | 'rest' | 'cache' | 'api' | 'client'>
74
+ ]>;
75
+ export declare const MESSAGE_POLL_VOTE_ADD: (_: BaseClient, data: GatewayMessagePollVoteDispatchData) => {
76
+ userId: string;
77
+ channelId: string;
78
+ messageId: string;
79
+ guildId?: string | undefined;
80
+ answerId: number;
81
+ };
82
+ export declare const MESSAGE_POLL_VOTE_REMOVE: (_: BaseClient, data: GatewayMessagePollVoteDispatchData) => {
83
+ userId: string;
84
+ channelId: string;
85
+ messageId: string;
86
+ guildId?: string | undefined;
87
+ answerId: number;
88
+ };
@@ -1,18 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MESSAGE_UPDATE = exports.MESSAGE_REACTION_REMOVE_EMOJI = exports.MESSAGE_REACTION_REMOVE_ALL = exports.MESSAGE_REACTION_REMOVE = exports.MESSAGE_REACTION_ADD = exports.MESSAGE_DELETE_BULK = exports.MESSAGE_DELETE = exports.MESSAGE_CREATE = void 0;
3
+ exports.MESSAGE_POLL_VOTE_REMOVE = exports.MESSAGE_POLL_VOTE_ADD = exports.MESSAGE_UPDATE = exports.MESSAGE_REACTION_REMOVE_EMOJI = exports.MESSAGE_REACTION_REMOVE_ALL = exports.MESSAGE_REACTION_REMOVE = exports.MESSAGE_REACTION_ADD = exports.MESSAGE_DELETE_BULK = exports.MESSAGE_DELETE = exports.MESSAGE_CREATE = void 0;
4
4
  const common_1 = require("../../common");
5
5
  const structures_1 = require("../../structures");
6
6
  const MESSAGE_CREATE = (self, data) => {
7
7
  return new structures_1.Message(self, data);
8
8
  };
9
9
  exports.MESSAGE_CREATE = MESSAGE_CREATE;
10
- const MESSAGE_DELETE = (_self, data) => {
11
- return (0, common_1.toCamelCase)(data);
10
+ const MESSAGE_DELETE = async (self, data) => {
11
+ return (await self.cache.messages?.get(data.id)) ?? (0, common_1.toCamelCase)(data);
12
12
  };
13
13
  exports.MESSAGE_DELETE = MESSAGE_DELETE;
14
- const MESSAGE_DELETE_BULK = (_self, data) => {
15
- return (0, common_1.toCamelCase)(data);
14
+ const MESSAGE_DELETE_BULK = async (self, data) => {
15
+ return {
16
+ ...data,
17
+ messages: await Promise.all(data.ids.map(id => self.cache.messages?.get(id))),
18
+ };
16
19
  };
17
20
  exports.MESSAGE_DELETE_BULK = MESSAGE_DELETE_BULK;
18
21
  const MESSAGE_REACTION_ADD = (_self, data) => {
@@ -31,7 +34,15 @@ const MESSAGE_REACTION_REMOVE_EMOJI = (_self, data) => {
31
34
  return (0, common_1.toCamelCase)(data);
32
35
  };
33
36
  exports.MESSAGE_REACTION_REMOVE_EMOJI = MESSAGE_REACTION_REMOVE_EMOJI;
34
- const MESSAGE_UPDATE = (self, data) => {
35
- return new structures_1.Message(self, data);
37
+ const MESSAGE_UPDATE = async (self, data) => {
38
+ return [await self.cache.messages?.get(data.id), new structures_1.Message(self, data)];
36
39
  };
37
40
  exports.MESSAGE_UPDATE = MESSAGE_UPDATE;
41
+ const MESSAGE_POLL_VOTE_ADD = (_, data) => {
42
+ return (0, common_1.toCamelCase)(data);
43
+ };
44
+ exports.MESSAGE_POLL_VOTE_ADD = MESSAGE_POLL_VOTE_ADD;
45
+ const MESSAGE_POLL_VOTE_REMOVE = (_, data) => {
46
+ return (0, common_1.toCamelCase)(data);
47
+ };
48
+ exports.MESSAGE_POLL_VOTE_REMOVE = MESSAGE_POLL_VOTE_REMOVE;
@@ -1,13 +1,5 @@
1
1
  import type { LocaleString } from 'discord-api-types/v10';
2
2
  import { BaseHandler } from '../common';
3
- export interface LangsHandlerLike {
4
- getKey: LangsHandler['getKey'];
5
- load: LangsHandler['load'];
6
- values: LangsHandler['values'];
7
- aliases: LangsHandler['aliases'];
8
- get: LangsHandler['get'];
9
- defaultLang?: LangsHandler['defaultLang'];
10
- }
11
3
  export declare class LangsHandler extends BaseHandler {
12
4
  values: Partial<Record<string, any>>;
13
5
  protected filter: (path: string) => boolean;
@@ -19,4 +11,8 @@ export declare class LangsHandler extends BaseHandler {
19
11
  get(locale?: string | undefined): import("..").DefaultLocale;
20
12
  };
21
13
  load(dir: string): Promise<void>;
14
+ setHandlers({ callback }: {
15
+ callback: LangsHandler['callback'];
16
+ }): void;
17
+ callback: (_locale: string, file: Record<string, any>) => Record<string, any> | false;
22
18
  }
@@ -34,9 +34,14 @@ class LangsHandler extends common_1.BaseHandler {
34
34
  const files = await this.loadFilesK(await this.getFiles(dir));
35
35
  for (const i of files) {
36
36
  const locale = i.name.split('.').slice(0, -1).join('.');
37
- this.values[locale] = i.file;
38
- await this.__callback?.(locale, i.file);
37
+ const result = this.callback(locale, i.file);
38
+ if (result)
39
+ this.values[locale] = result;
39
40
  }
40
41
  }
42
+ setHandlers({ callback }) {
43
+ this.callback = callback;
44
+ }
45
+ callback = (_locale, file) => file;
41
46
  }
42
47
  exports.LangsHandler = LangsHandler;
@@ -8,16 +8,16 @@ export declare class AutoModerationRule extends DiscordBase<APIAutoModerationRul
8
8
  constructor(client: UsingClient, data: APIAutoModerationRule);
9
9
  fetchCreator(force?: boolean): Promise<import("./GuildMember").GuildMember>;
10
10
  guild(force?: boolean): Promise<import("./Guild").Guild<"cached"> | import("./Guild").Guild<"api">>;
11
- fetch(): Promise<APIAutoModerationRule>;
12
- edit(body: ObjectToLower<RESTPatchAPIAutoModerationRuleJSONBody>, reason?: string): Promise<APIAutoModerationRule>;
11
+ fetch(): Promise<AutoModerationRule>;
12
+ edit(body: ObjectToLower<RESTPatchAPIAutoModerationRuleJSONBody>, reason?: string): Promise<AutoModerationRule>;
13
13
  delete(reason?: string): Promise<never>;
14
14
  static methods({ client, guildId }: MethodContext<{
15
15
  guildId: string;
16
16
  }>): {
17
- list: () => Promise<import("discord-api-types/v10").RESTGetAPIAutoModerationRulesResult>;
18
- create: (body: RESTPostAPIAutoModerationRuleJSONBody) => Promise<APIAutoModerationRule>;
17
+ list: () => Promise<AutoModerationRule[]>;
18
+ create: (body: RESTPostAPIAutoModerationRuleJSONBody) => Promise<AutoModerationRule>;
19
19
  delete: (ruleId: string, reason?: string) => Promise<never>;
20
- fetch: (ruleId: string) => Promise<APIAutoModerationRule>;
21
- edit: (ruleId: string, body: RESTPatchAPIAutoModerationRuleJSONBody, reason?: string) => Promise<APIAutoModerationRule>;
20
+ fetch: (ruleId: string) => Promise<AutoModerationRule>;
21
+ edit: (ruleId: string, body: RESTPatchAPIAutoModerationRuleJSONBody, reason?: string) => Promise<AutoModerationRule>;
22
22
  };
23
23
  }
@@ -1,9 +1,11 @@
1
1
  import type { APIGuild, GatewayGuildCreateDispatchData } from 'discord-api-types/v10';
2
2
  import type { UsingClient } from '../commands';
3
3
  import type { ObjectToLower, StructPropState, StructStates, ToClass } from '../common/types/util';
4
+ import { AutoModerationRule } from './AutoModerationRule';
4
5
  import { GuildEmoji } from './GuildEmoji';
5
6
  import { GuildMember } from './GuildMember';
6
7
  import { GuildRole } from './GuildRole';
8
+ import { GuildTemplate } from './GuildTemplate';
7
9
  import { Sticker } from './Sticker';
8
10
  import { BaseGuild } from './extra/BaseGuild';
9
11
  import type { DiscordBase } from './extra/DiscordBase';
@@ -23,12 +25,12 @@ export declare class Guild<State extends StructStates = 'api'> extends Guild_bas
23
25
  get maxEmojis(): MaxEmojis;
24
26
  fetchOwner(force?: boolean): Promise<null> | Promise<GuildMember>;
25
27
  templates: {
26
- fetch: (code: string) => Promise<import("discord-api-types/v10").APITemplate>;
27
- list: () => Promise<import("discord-api-types/v10").RESTGetAPIGuildTemplatesResult>;
28
- create: (body: import("discord-api-types/v10").RESTPostAPIGuildTemplatesJSONBody) => Promise<import("discord-api-types/v10").APITemplate>;
29
- sync: (code: string) => Promise<import("discord-api-types/v10").APITemplate>;
30
- edit: (code: string, body: import("discord-api-types/utils/internals").AddUndefinedToPossiblyUndefinedPropertiesOfInterface<Partial<import("discord-api-types/v10").RESTPostAPIGuildTemplatesJSONBody>>) => Promise<import("discord-api-types/v10").APITemplate>;
31
- delete: (code: string) => Promise<import("discord-api-types/v10").APITemplate>;
28
+ fetch: (code: string) => Promise<GuildTemplate>;
29
+ list: () => Promise<GuildTemplate[]>;
30
+ create: (body: import("discord-api-types/v10").RESTPostAPIGuildTemplatesJSONBody) => Promise<GuildTemplate>;
31
+ sync: (code: string) => Promise<GuildTemplate>;
32
+ edit: (code: string, body: import("discord-api-types/utils/internals").AddUndefinedToPossiblyUndefinedPropertiesOfInterface<Partial<import("discord-api-types/v10").RESTPostAPIGuildTemplatesJSONBody>>) => Promise<GuildTemplate>;
33
+ delete: (code: string) => Promise<GuildTemplate>;
32
34
  };
33
35
  stickers: {
34
36
  list: () => Promise<Sticker[]>;
@@ -49,17 +51,17 @@ export declare class Guild<State extends StructStates = 'api'> extends Guild_bas
49
51
  list: (query?: import("discord-api-types/v10").RESTGetAPIGuildMembersQuery | undefined, force?: boolean) => Promise<GuildMember[]>;
50
52
  };
51
53
  moderationRules: {
52
- list: () => Promise<import("discord-api-types/v10").RESTGetAPIAutoModerationRulesResult>;
53
- create: (body: import("discord-api-types/v10").RESTPostAPIAutoModerationRuleJSONBody) => Promise<import("discord-api-types/v10").APIAutoModerationRule>;
54
+ list: () => Promise<AutoModerationRule[]>;
55
+ create: (body: import("discord-api-types/v10").RESTPostAPIAutoModerationRuleJSONBody) => Promise<AutoModerationRule>;
54
56
  delete: (ruleId: string, reason?: string | undefined) => Promise<never>;
55
- fetch: (ruleId: string) => Promise<import("discord-api-types/v10").APIAutoModerationRule>;
56
- edit: (ruleId: string, body: import("discord-api-types/v10").RESTPatchAPIAutoModerationRuleJSONBody, reason?: string | undefined) => Promise<import("discord-api-types/v10").APIAutoModerationRule>;
57
+ fetch: (ruleId: string) => Promise<AutoModerationRule>;
58
+ edit: (ruleId: string, body: import("discord-api-types/v10").RESTPatchAPIAutoModerationRuleJSONBody, reason?: string | undefined) => Promise<AutoModerationRule>;
57
59
  };
58
60
  roles: {
59
- create: (body: import("discord-api-types/v10").RESTPostAPIGuildRoleJSONBody) => Promise<any>;
61
+ create: (body: import("discord-api-types/v10").RESTPostAPIGuildRoleJSONBody) => Promise<GuildRole>;
60
62
  list: (force?: boolean) => Promise<GuildRole[]>;
61
- edit: (roleId: string, body: import("discord-api-types/v10").RESTPatchAPIGuildRoleJSONBody, reason?: string | undefined) => Promise<any>;
62
- delete: (roleId: string, reason?: string | undefined) => Promise<void | undefined>;
63
+ edit: (roleId: string, body: import("discord-api-types/v10").RESTPatchAPIGuildRoleJSONBody, reason?: string | undefined) => Promise<GuildRole>;
64
+ delete: (roleId: string, reason?: string | undefined) => Promise<GuildRole>;
63
65
  editPositions: (body: import("discord-api-types/v10").RESTPatchAPIGuildRolePositionsJSONBody) => Promise<GuildRole[]>;
64
66
  };
65
67
  channels: {
@@ -1,5 +1,5 @@
1
1
  import type { APIEmoji, RESTPatchAPIChannelJSONBody, RESTPatchAPIGuildEmojiJSONBody } from 'discord-api-types/v10';
2
- import type { BaseImageURLOptions } from '../api';
2
+ import type { BaseCDNUrlOptions } from '../api';
3
3
  import type { UsingClient } from '../commands';
4
4
  import type { EmojiShorter, MethodContext, ObjectToLower } from '../common';
5
5
  import { DiscordBase } from './extra/DiscordBase';
@@ -12,7 +12,7 @@ export declare class GuildEmoji extends DiscordBase {
12
12
  edit(body: RESTPatchAPIChannelJSONBody, reason?: string): Promise<GuildEmoji>;
13
13
  delete(reason?: string): Promise<void>;
14
14
  fetch(force?: boolean): Promise<GuildEmoji>;
15
- url(options?: BaseImageURLOptions): string;
15
+ url(options?: BaseCDNUrlOptions): string;
16
16
  toString(): string;
17
17
  toJSON(): {
18
18
  id: string;
@@ -23,7 +23,7 @@ class GuildEmoji extends DiscordBase_1.DiscordBase {
23
23
  return this.client.emojis.fetch(this.guildId, this.id, force);
24
24
  }
25
25
  url(options) {
26
- return this.rest.cdn.emoji(this.id, options);
26
+ return this.rest.cdn.emojis(this.id).get(options);
27
27
  }
28
28
  toString() {
29
29
  return `<${this.animated ? 'a' : ''}:${this.name}:${this.id}>`;
@@ -127,7 +127,7 @@ class GuildMember extends BaseGuildMember {
127
127
  if (!this.avatar) {
128
128
  return this.user.avatarURL(options);
129
129
  }
130
- return this.rest.cdn.guildMemberAvatar(this.guildId, this.id, this.avatar, options);
130
+ return this.rest.cdn.guilds(this.guildId).users(this.id).avatars(this.avatar).get(options);
131
131
  }
132
132
  bannerURL(options) {
133
133
  return this.user.bannerURL(options);
@@ -10,15 +10,15 @@ export declare class GuildRole extends DiscordBase {
10
10
  permissions: PermissionsBitField;
11
11
  constructor(client: UsingClient, data: APIRole, guildId: string);
12
12
  guild(force?: boolean): Promise<import("./Guild").Guild<"cached"> | import("./Guild").Guild<"api">> | undefined;
13
- edit(body: RESTPatchAPIGuildRoleJSONBody, reason?: string): Promise<any>;
14
- delete(reason?: string): Promise<void | undefined>;
13
+ edit(body: RESTPatchAPIGuildRoleJSONBody, reason?: string): Promise<GuildRole>;
14
+ delete(reason?: string): Promise<GuildRole>;
15
15
  static methods(ctx: MethodContext<{
16
16
  guildId: string;
17
17
  }>): {
18
- create: (body: RESTPostAPIGuildRoleJSONBody) => Promise<any>;
18
+ create: (body: RESTPostAPIGuildRoleJSONBody) => Promise<GuildRole>;
19
19
  list: (force?: boolean) => Promise<GuildRole[]>;
20
- edit: (roleId: string, body: RESTPatchAPIGuildRoleJSONBody, reason?: string) => Promise<any>;
21
- delete: (roleId: string, reason?: string) => Promise<void | undefined>;
20
+ edit: (roleId: string, body: RESTPatchAPIGuildRoleJSONBody, reason?: string) => Promise<GuildRole>;
21
+ delete: (roleId: string, reason?: string) => Promise<GuildRole>;
22
22
  editPositions: (body: RESTPatchAPIGuildRolePositionsJSONBody) => Promise<GuildRole[]>;
23
23
  };
24
24
  }
@@ -7,18 +7,18 @@ export interface GuildTemplate extends Base, ObjectToLower<APITemplate> {
7
7
  export declare class GuildTemplate extends Base {
8
8
  constructor(client: UsingClient, data: APITemplate);
9
9
  guild(force?: boolean): Promise<import("./Guild").Guild<"cached"> | import("./Guild").Guild<"api">>;
10
- fetch(): Promise<APITemplate>;
11
- sync(): Promise<APITemplate>;
12
- edit(body: RESTPatchAPIGuildTemplateJSONBody): Promise<APITemplate>;
13
- delete(): Promise<APITemplate>;
10
+ fetch(): Promise<GuildTemplate>;
11
+ sync(): Promise<GuildTemplate>;
12
+ edit(body: RESTPatchAPIGuildTemplateJSONBody): Promise<GuildTemplate>;
13
+ delete(): Promise<GuildTemplate>;
14
14
  static methods(ctx: MethodContext<{
15
15
  guildId: string;
16
16
  }>): {
17
- fetch: (code: string) => Promise<APITemplate>;
18
- list: () => Promise<import("discord-api-types/v10").RESTGetAPIGuildTemplatesResult>;
19
- create: (body: RESTPostAPIGuildTemplatesJSONBody) => Promise<APITemplate>;
20
- sync: (code: string) => Promise<APITemplate>;
21
- edit: (code: string, body: RESTPatchAPIGuildTemplateJSONBody) => Promise<APITemplate>;
22
- delete: (code: string) => Promise<APITemplate>;
17
+ fetch: (code: string) => Promise<GuildTemplate>;
18
+ list: () => Promise<GuildTemplate[]>;
19
+ create: (body: RESTPostAPIGuildTemplatesJSONBody) => Promise<GuildTemplate>;
20
+ sync: (code: string) => Promise<GuildTemplate>;
21
+ edit: (code: string, body: RESTPatchAPIGuildTemplateJSONBody) => Promise<GuildTemplate>;
22
+ delete: (code: string) => Promise<GuildTemplate>;
23
23
  };
24
24
  }
@@ -55,11 +55,11 @@ export declare class Interaction<FromGuild extends boolean = boolean, Type exten
55
55
  write<FR extends boolean = false>(body: InteractionCreateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage, void>>;
56
56
  modal(body: ModalCreateBodyRequest): Promise<void>;
57
57
  editOrReply<FR extends boolean = false>(body: InteractionCreateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage, void>>;
58
- editMessage(messageId: string, body: InteractionMessageUpdateBodyRequest): Promise<Message>;
59
- editResponse(body: InteractionMessageUpdateBodyRequest): Promise<Message>;
58
+ editMessage(messageId: string, body: InteractionMessageUpdateBodyRequest): Promise<WebhookMessage>;
59
+ editResponse(body: InteractionMessageUpdateBodyRequest): Promise<WebhookMessage>;
60
60
  deleteResponse(): Promise<void | undefined>;
61
61
  deleteMessage(messageId: string): Promise<void | undefined>;
62
- createResponse({ files, ...body }: MessageWebhookCreateBodyRequest): Promise<Message>;
62
+ followup(body: MessageWebhookCreateBodyRequest): Promise<WebhookMessage>;
63
63
  }
64
64
  export declare class ApplicationCommandInteraction<FromGuild extends boolean = boolean, Type extends APIApplicationCommandInteraction = APIApplicationCommandInteraction> extends Interaction<FromGuild, Type> {
65
65
  type: ApplicationCommandType;
@@ -55,19 +55,21 @@ class BaseInteraction extends DiscordBase_1.DiscordBase {
55
55
  case v10_1.InteractionResponseType.DeferredChannelMessageWithSource:
56
56
  return body;
57
57
  case v10_1.InteractionResponseType.ChannelMessageWithSource:
58
- case v10_1.InteractionResponseType.UpdateMessage:
58
+ case v10_1.InteractionResponseType.UpdateMessage: {
59
+ const poll = body.poll;
59
60
  return {
60
61
  type: body.type,
61
- // @ts-ignore
62
+ //@ts-ignore
62
63
  data: {
63
- // @ts-ignore
64
64
  ...(body.data ?? {}),
65
- // @ts-ignore
65
+ //@ts-ignore
66
66
  components: body.data?.components?.map(x => (x instanceof builders_1.ActionRow ? x.toJSON() : x)) ?? undefined,
67
67
  embeds: body.data?.embeds?.map(x => (x instanceof builders_1.Embed ? x.toJSON() : x)) ?? undefined,
68
68
  attachments: body.data?.attachments?.map((x, i) => ({ id: i, ...(0, builders_1.resolveAttachment)(x) })) ?? undefined,
69
+ poll: poll ? (poll instanceof builders_1.PollBuilder ? poll.toJSON() : poll) : undefined,
69
70
  },
70
71
  };
72
+ }
71
73
  case v10_1.InteractionResponseType.Modal:
72
74
  return {
73
75
  type: body.type,
@@ -87,38 +89,34 @@ class BaseInteraction extends DiscordBase_1.DiscordBase {
87
89
  }
88
90
  }
89
91
  static transformBody(body) {
92
+ const poll = body.poll;
90
93
  return {
91
94
  ...body,
92
95
  components: body.components?.map(x => (x instanceof builders_1.ActionRow ? x.toJSON() : x)) ?? undefined,
93
96
  embeds: body?.embeds?.map(x => (x instanceof builders_1.Embed ? x.toJSON() : x)) ?? undefined,
94
- // attachments: body.attachments?.map((x, i) => ({ id: i, ...resolveAttachment(x) })) ?? undefined,
97
+ poll: poll ? (poll instanceof builders_1.PollBuilder ? poll.toJSON() : poll) : undefined,
95
98
  };
96
99
  }
97
- matchReplied(data, type, filesParsed) {
98
- this.replied = (this.__reply ?? this.api.interactions(this.id)(this.token).callback.post)({
99
- // @ts-expect-error
100
- body: BaseInteraction.transformBodyRequest({ data, type }),
101
- files: filesParsed,
102
- }).then(() => (this.replied = true));
100
+ async matchReplied(body) {
101
+ if (this.__reply) {
102
+ //@ts-expect-error
103
+ const { files, ...data } = body.data ?? {};
104
+ return (this.replied = this.__reply({
105
+ body: BaseInteraction.transformBodyRequest({ data, type: body.type }),
106
+ files: files ? await (0, builders_1.resolveFiles)(files) : undefined,
107
+ }).then(() => (this.replied = true)));
108
+ }
109
+ return (this.replied = this.client.interactions.reply(this.id, this.token, body).then(() => (this.replied = true)));
103
110
  }
104
111
  async reply(body) {
105
112
  if (this.replied) {
106
113
  throw new Error('Interaction already replied');
107
114
  }
115
+ await this.matchReplied(body);
108
116
  // @ts-expect-error
109
- if (body.data?.files) {
110
- // @ts-expect-error
111
- const { files, ...rest } = body.data;
112
- this.matchReplied(rest, body.type, await (0, builders_1.resolveFiles)(files));
113
- // @ts-expect-error
114
- }
115
- else
116
- this.matchReplied(body.data, body.type);
117
- // @ts-expect-error
118
- if (body.data instanceof builders_1.Modal)
117
+ if (body.data instanceof builders_1.Modal && body.data.__exec)
119
118
  // @ts-expect-error
120
119
  this.client.components.modals.set(this.user.id, body.data.__exec);
121
- await this.replied;
122
120
  }
123
121
  deferReply(flags) {
124
122
  return this.reply({
@@ -191,7 +189,7 @@ class AutocompleteInteraction extends BaseInteraction {
191
189
  exports.AutocompleteInteraction = AutocompleteInteraction;
192
190
  class Interaction extends BaseInteraction {
193
191
  fetchMessage(messageId) {
194
- return this.client.webhooks.fetchMessage(this.applicationId, this.token, messageId);
192
+ return this.client.interactions.fetchResponse(this.token, messageId);
195
193
  }
196
194
  fetchResponse() {
197
195
  return this.fetchMessage('@original');
@@ -218,16 +216,8 @@ class Interaction extends BaseInteraction {
218
216
  }
219
217
  return this.write(body, fetchReply);
220
218
  }
221
- async editMessage(messageId, body) {
222
- const { files, ...data } = body;
223
- const apiMessage = await this.api
224
- .webhooks(this.applicationId)(this.token)
225
- .messages(messageId)
226
- .patch({
227
- body: BaseInteraction.transformBody(data),
228
- files: files ? await (0, builders_1.resolveFiles)(files) : undefined,
229
- });
230
- return new Message_1.Message(this.client, apiMessage);
219
+ editMessage(messageId, body) {
220
+ return this.client.interactions.editMessage(this.token, messageId, body);
231
221
  }
232
222
  editResponse(body) {
233
223
  return this.editMessage('@original', body);
@@ -236,21 +226,10 @@ class Interaction extends BaseInteraction {
236
226
  return this.deleteMessage('@original');
237
227
  }
238
228
  deleteMessage(messageId) {
239
- return this.api
240
- .webhooks(this.applicationId)(this.token)
241
- .messages(messageId)
242
- .delete()
243
- .then(() => this.client.components?.onMessageDelete(messageId === '@original' ? this.id : messageId));
244
- }
245
- async createResponse({ files, ...body }) {
246
- files ??= files ? await (0, builders_1.resolveFiles)(files) : undefined;
247
- const apiMessage = await this.api
248
- .webhooks(this.applicationId)(this.token)
249
- .post({
250
- body: BaseInteraction.transformBody(body),
251
- files: files,
252
- });
253
- return new Message_1.Message(this.client, apiMessage);
229
+ return this.client.interactions.deleteResponse(this.id, this.token, messageId);
230
+ }
231
+ async followup(body) {
232
+ return this.client.interactions.followup(this.token, body);
254
233
  }
255
234
  }
256
235
  exports.Interaction = Interaction;
@@ -10,8 +10,9 @@ import { GuildMember } from './GuildMember';
10
10
  import { User } from './User';
11
11
  import type { MessageWebhookMethodEditParams, MessageWebhookMethodWriteParams } from './Webhook';
12
12
  import { DiscordBase } from './extra/DiscordBase';
13
+ import { Poll } from '..';
13
14
  export type MessageData = APIMessage | GatewayMessageCreateDispatchData;
14
- export interface BaseMessage extends DiscordBase, ObjectToLower<Omit<MessageData, 'timestamp' | 'author' | 'mentions' | 'components'>> {
15
+ export interface BaseMessage extends DiscordBase, ObjectToLower<Omit<MessageData, 'timestamp' | 'author' | 'mentions' | 'components' | 'poll'>> {
15
16
  }
16
17
  export declare class BaseMessage extends DiscordBase {
17
18
  guildId: string | undefined;
@@ -19,6 +20,7 @@ export declare class BaseMessage extends DiscordBase {
19
20
  author: User;
20
21
  member?: GuildMember;
21
22
  components: MessageActionRowComponent<ActionRowMessageComponents>[];
23
+ poll?: Poll;
22
24
  mentions: {
23
25
  roles: string[];
24
26
  channels: APIChannelMention[];
@@ -27,7 +29,7 @@ export declare class BaseMessage extends DiscordBase {
27
29
  constructor(client: UsingClient, data: MessageData);
28
30
  get user(): User;
29
31
  createComponentCollector(options?: ListenerOptions): {
30
- run<T extends import("./Interaction").StringSelectMenuInteraction<string[]> | import("./Interaction").ComponentInteraction<boolean, import("discord-api-types/v10").APIMessageComponentInteraction> = import("./Interaction").StringSelectMenuInteraction<string[]> | import("./Interaction").ComponentInteraction<boolean, import("discord-api-types/v10").APIMessageComponentInteraction>>(customId: string | RegExp | string[], callback: import("../builders").ComponentCallback<T>): any;
32
+ run<T extends import("./Interaction").StringSelectMenuInteraction<string[]> | import("./Interaction").ComponentInteraction<boolean, import("discord-api-types/v10").APIMessageComponentInteraction> = import("./Interaction").StringSelectMenuInteraction<string[]> | import("./Interaction").ComponentInteraction<boolean, import("discord-api-types/v10").APIMessageComponentInteraction>>(customId: string | RegExp | string[], callback: import("..").ComponentCallback<T>): any;
31
33
  stop(reason?: string | undefined): any;
32
34
  };
33
35
  get url(): string;
@@ -36,7 +38,7 @@ export declare class BaseMessage extends DiscordBase {
36
38
  react(emoji: EmojiResolvable): Promise<void>;
37
39
  private patch;
38
40
  }
39
- export interface Message extends BaseMessage, ObjectToLower<Omit<MessageData, 'timestamp' | 'author' | 'mentions' | 'components'>> {
41
+ export interface Message extends BaseMessage, ObjectToLower<Omit<MessageData, 'timestamp' | 'author' | 'mentions' | 'components' | 'poll'>> {
40
42
  }
41
43
  export declare class Message extends BaseMessage {
42
44
  constructor(client: UsingClient, data: MessageData);
@@ -6,12 +6,14 @@ const GuildMember_1 = require("./GuildMember");
6
6
  const User_1 = require("./User");
7
7
  const DiscordBase_1 = require("./extra/DiscordBase");
8
8
  const functions_1 = require("./extra/functions");
9
+ const __1 = require("..");
9
10
  class BaseMessage extends DiscordBase_1.DiscordBase {
10
11
  guildId;
11
12
  timestamp;
12
13
  author;
13
14
  member;
14
15
  components;
16
+ poll;
15
17
  mentions;
16
18
  constructor(client, data) {
17
19
  super(client, data);
@@ -70,6 +72,9 @@ class BaseMessage extends DiscordBase_1.DiscordBase {
70
72
  }, m, this.guildId))
71
73
  : data.mentions.map(u => new User_1.User(this.client, u));
72
74
  }
75
+ if (data.poll) {
76
+ this.poll = new __1.Poll(this.client, data.poll, this.channelId, this.id);
77
+ }
73
78
  }
74
79
  }
75
80
  exports.BaseMessage = BaseMessage;
@@ -0,0 +1,15 @@
1
+ import type { APIPoll } from 'discord-api-types/v10';
2
+ import { type ObjectToLower } from '../common';
3
+ import { Base } from './extra/Base';
4
+ import type { UsingClient } from '../commands';
5
+ import type { ValidAnswerId } from '../api/Routes/channels';
6
+ export interface Poll extends ObjectToLower<Omit<APIPoll, 'expiry'>> {
7
+ }
8
+ export declare class Poll extends Base {
9
+ readonly channelId: string;
10
+ readonly messageId: string;
11
+ expiry: number;
12
+ constructor(client: UsingClient, data: APIPoll, channelId: string, messageId: string);
13
+ end(): Promise<import("./Message").Message>;
14
+ getAnswerVoters(id: ValidAnswerId): Promise<import("./User").User[]>;
15
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Poll = void 0;
4
+ const common_1 = require("../common");
5
+ const Base_1 = require("./extra/Base");
6
+ class Poll extends Base_1.Base {
7
+ channelId;
8
+ messageId;
9
+ expiry;
10
+ constructor(client, data, channelId, messageId) {
11
+ super(client);
12
+ this.channelId = channelId;
13
+ this.messageId = messageId;
14
+ this.expiry = Date.parse(data.expiry);
15
+ Object.assign(this, (0, common_1.toCamelCase)(data));
16
+ }
17
+ end() {
18
+ return this.client.messages.endPoll(this.channelId, this.messageId);
19
+ }
20
+ getAnswerVoters(id) {
21
+ if (!this.answers.find(x => x.answerId === id))
22
+ throw new Error('Invalid answer id');
23
+ return this.client.messages.getAnswerVoters(this.channelId, this.messageId, id);
24
+ }
25
+ }
26
+ exports.Poll = Poll;