seyfert 1.0.1 → 1.1.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 (103) hide show
  1. package/lib/api/CDN.d.ts +1 -1
  2. package/lib/api/CDN.js +0 -2
  3. package/lib/api/Router.js +2 -2
  4. package/lib/api/Routes/applications.d.ts +29 -33
  5. package/lib/api/Routes/channels.d.ts +11 -17
  6. package/lib/api/Routes/interactions.d.ts +3 -7
  7. package/lib/api/Routes/webhooks.d.ts +4 -6
  8. package/lib/builders/Attachment.d.ts +2 -3
  9. package/lib/cache/adapters/redis.js +6 -0
  10. package/lib/cache/adapters/workeradapter.d.ts +4 -4
  11. package/lib/cache/adapters/workeradapter.js +10 -5
  12. package/lib/cache/index.d.ts +4 -5
  13. package/lib/cache/index.js +4 -3
  14. package/lib/cache/resources/default/base.d.ts +2 -1
  15. package/lib/cache/resources/default/guild-based.d.ts +2 -1
  16. package/lib/cache/resources/default/guild-based.js +6 -6
  17. package/lib/cache/resources/default/guild-related.d.ts +2 -1
  18. package/lib/cache/resources/default/guild-related.js +1 -1
  19. package/lib/cache/resources/guilds.js +2 -1
  20. package/lib/cache/resources/overwrites.d.ts +1 -1
  21. package/lib/cache/resources/overwrites.js +7 -1
  22. package/lib/client/base.d.ts +18 -170
  23. package/lib/client/base.js +11 -14
  24. package/lib/client/client.d.ts +5 -0
  25. package/lib/client/client.js +4 -1
  26. package/lib/client/oninteractioncreate.js +2 -2
  27. package/lib/client/onmessagecreate.js +188 -152
  28. package/lib/client/workerclient.d.ts +1 -0
  29. package/lib/client/workerclient.js +36 -15
  30. package/lib/collection.js +2 -2
  31. package/lib/commands/applications/chat.d.ts +15 -7
  32. package/lib/commands/applications/chat.js +7 -7
  33. package/lib/commands/applications/chatcontext.d.ts +5 -3
  34. package/lib/commands/applications/chatcontext.js +6 -1
  35. package/lib/commands/applications/menu.d.ts +5 -1
  36. package/lib/commands/applications/menu.js +4 -0
  37. package/lib/commands/applications/menucontext.d.ts +4 -2
  38. package/lib/commands/applications/menucontext.js +6 -1
  39. package/lib/commands/applications/options.d.ts +1 -2
  40. package/lib/commands/decorators.d.ts +17 -5
  41. package/lib/commands/decorators.js +17 -7
  42. package/lib/commands/handler.d.ts +5 -5
  43. package/lib/commands/handler.js +40 -36
  44. package/lib/commands/optionresolver.d.ts +11 -4
  45. package/lib/commands/optionresolver.js +6 -4
  46. package/lib/common/index.d.ts +7 -0
  47. package/lib/common/index.js +7 -0
  48. package/lib/common/it/utils.js +2 -0
  49. package/lib/common/shorters/channels.d.ts +67 -129
  50. package/lib/common/shorters/channels.js +119 -135
  51. package/lib/common/shorters/emojis.d.ts +47 -0
  52. package/lib/common/shorters/emojis.js +80 -0
  53. package/lib/common/shorters/guilds.d.ts +22 -249
  54. package/lib/common/shorters/guilds.js +51 -140
  55. package/lib/common/shorters/members.d.ts +82 -108
  56. package/lib/common/shorters/members.js +151 -166
  57. package/lib/common/shorters/messages.d.ts +11 -23
  58. package/lib/common/shorters/messages.js +58 -104
  59. package/lib/common/shorters/reactions.d.ts +10 -0
  60. package/lib/common/shorters/reactions.js +45 -0
  61. package/lib/common/shorters/roles.d.ts +39 -7
  62. package/lib/common/shorters/roles.js +74 -42
  63. package/lib/common/shorters/templates.d.ts +6 -8
  64. package/lib/common/shorters/templates.js +17 -21
  65. package/lib/common/shorters/users.d.ts +4 -0
  66. package/lib/common/shorters/users.js +30 -0
  67. package/lib/common/shorters/webhook.d.ts +62 -26
  68. package/lib/common/shorters/webhook.js +113 -58
  69. package/lib/common/types/options.d.ts +2 -2
  70. package/lib/components/handler.d.ts +10 -7
  71. package/lib/components/handler.js +20 -5
  72. package/lib/index.d.ts +4 -2
  73. package/lib/langs/handler.js +7 -2
  74. package/lib/structures/AutoModerationRule.d.ts +2 -2
  75. package/lib/structures/ClientUser.d.ts +2 -2
  76. package/lib/structures/Guild.d.ts +2 -2
  77. package/lib/structures/GuildEmoji.d.ts +4 -4
  78. package/lib/structures/GuildEmoji.js +7 -7
  79. package/lib/structures/GuildMember.d.ts +6 -6
  80. package/lib/structures/GuildMember.js +2 -2
  81. package/lib/structures/GuildPreview.d.ts +2 -2
  82. package/lib/structures/GuildRole.d.ts +2 -2
  83. package/lib/structures/GuildTemplate.d.ts +2 -2
  84. package/lib/structures/Interaction.d.ts +7 -8
  85. package/lib/structures/Interaction.js +1 -1
  86. package/lib/structures/Message.d.ts +7 -6
  87. package/lib/structures/Message.js +7 -4
  88. package/lib/structures/Sticker.d.ts +2 -2
  89. package/lib/structures/Webhook.d.ts +2 -2
  90. package/lib/structures/Webhook.js +3 -3
  91. package/lib/structures/channels.d.ts +19 -20
  92. package/lib/structures/channels.js +13 -25
  93. package/lib/structures/extra/Base.d.ts +1 -2
  94. package/lib/structures/extra/DiscordBase.d.ts +2 -2
  95. package/lib/websocket/constants/index.js +1 -0
  96. package/lib/websocket/discord/shard.js +4 -2
  97. package/lib/websocket/discord/sharder.d.ts +3 -0
  98. package/lib/websocket/discord/sharder.js +12 -5
  99. package/lib/websocket/discord/shared.d.ts +1 -0
  100. package/lib/websocket/discord/worker.d.ts +2 -1
  101. package/lib/websocket/discord/workermanager.d.ts +8 -3
  102. package/lib/websocket/discord/workermanager.js +78 -30
  103. package/package.json +8 -6
@@ -3,113 +3,87 @@ import { GuildMember } from '../../structures';
3
3
  import { BaseShorter } from './base';
4
4
  export declare class MemberShorter extends BaseShorter {
5
5
  /**
6
- * Provides access to member-related functionality in a guild.
6
+ * Resolves a member in the guild based on the provided GuildMemberResolvable.
7
+ * @param guildId The ID of the guild.
8
+ * @param resolve The GuildMemberResolvable to resolve.
9
+ * @returns A Promise that resolves to the resolved member.
7
10
  */
8
- get members(): {
9
- /**
10
- * Resolves a member in the guild based on the provided GuildMemberResolvable.
11
- * @param guildId The ID of the guild.
12
- * @param resolve The GuildMemberResolvable to resolve.
13
- * @returns A Promise that resolves to the resolved member.
14
- */
15
- resolve: (guildId: string, resolve: GuildMemberResolvable) => Promise<GuildMember | undefined>;
16
- /**
17
- * Searches for members in the guild based on the provided query.
18
- * @param guildId The ID of the guild.
19
- * @param query The query parameters for searching members.
20
- * @returns A Promise that resolves to an array of matched members.
21
- */
22
- search: (guildId: string, query?: RESTGetAPIGuildMembersSearchQuery) => Promise<GuildMember[]>;
23
- /**
24
- * Unbans a member from the guild.
25
- * @param guildId The ID of the guild.
26
- * @param memberId The ID of the member to unban.
27
- * @param body The request body for unbanning the member.
28
- * @param reason The reason for unbanning the member.
29
- */
30
- unban: (guildId: string, memberId: string, body?: RESTPutAPIGuildBanJSONBody, reason?: string) => Promise<void>;
31
- /**
32
- * Bans a member from the guild.
33
- * @param guildId The ID of the guild.
34
- * @param memberId The ID of the member to ban.
35
- * @param body The request body for banning the member.
36
- * @param reason The reason for banning the member.
37
- */
38
- ban: (guildId: string, memberId: string, body?: RESTPutAPIGuildBanJSONBody, reason?: string) => Promise<void>;
39
- /**
40
- * Kicks a member from the guild.
41
- * @param guildId The ID of the guild.
42
- * @param memberId The ID of the member to kick.
43
- * @param reason The reason for kicking the member.
44
- */
45
- kick: (guildId: string, memberId: string, reason?: string) => Promise<void>;
46
- /**
47
- * Edits a member in the guild.
48
- * @param guildId The ID of the guild.
49
- * @param memberId The ID of the member to edit.
50
- * @param body The data to update the member with.
51
- * @param reason The reason for editing the member.
52
- * @returns A Promise that resolves to the edited member.
53
- */
54
- edit: (guildId: string, memberId: string, body: RESTPatchAPIGuildMemberJSONBody, reason?: string) => Promise<GuildMember>;
55
- /**
56
- * Adds a member to the guild.
57
- * @param guildId The ID of the guild.
58
- * @param memberId The ID of the member to add.
59
- * @param body The request body for adding the member.
60
- * @returns A Promise that resolves to the added member.
61
- */
62
- add: (guildId: string, memberId: string, body: RESTPutAPIGuildMemberJSONBody) => Promise<GuildMember | undefined>;
63
- /**
64
- * Fetches a member from the guild.
65
- * @param guildId The ID of the guild.
66
- * @param memberId The ID of the member to fetch.
67
- * @param force Whether to force fetching the member from the API even if it exists in the cache.
68
- * @returns A Promise that resolves to the fetched member.
69
- */
70
- fetch: (guildId: string, memberId: string, force?: boolean) => Promise<GuildMember>;
71
- /**
72
- * Lists members in the guild based on the provided query.
73
- * @param guildId The ID of the guild.
74
- * @param query The query parameters for listing members.
75
- * @param force Whether to force listing members from the API even if they exist in the cache.
76
- * @returns A Promise that resolves to an array of listed members.
77
- */
78
- list: (guildId: string, query?: RESTGetAPIGuildMembersQuery, force?: boolean) => Promise<GuildMember[]>;
79
- /**
80
- * Provides methods to add and remove roles from a guild member.
81
- */
82
- roles: {
83
- /**
84
- * Adds a role to a guild member.
85
- * @param guildId The ID of the guild.
86
- * @param memberId The ID of the member to add the role to.
87
- * @param id The ID of the role to add.
88
- */
89
- add: (guildId: string, memberId: string, id: string) => Promise<void>;
90
- /**
91
- * Removes a role from a guild member.
92
- * @param guildId The ID of the guild.
93
- * @param memberId The ID of the member to remove the role from.
94
- * @param id The ID of the role to remove.
95
- */
96
- remove: (guildId: string, memberId: string, id: string) => Promise<void>;
97
- };
98
- };
99
- get roles(): {
100
- /**
101
- * Adds a role to a guild member.
102
- * @param guildId The ID of the guild.
103
- * @param memberId The ID of the member to add the role to.
104
- * @param id The ID of the role to add.
105
- */
106
- add: (guildId: string, memberId: string, id: string) => Promise<void>;
107
- /**
108
- * Removes a role from a guild member.
109
- * @param guildId The ID of the guild.
110
- * @param memberId The ID of the member to remove the role from.
111
- * @param id The ID of the role to remove.
112
- */
113
- remove: (guildId: string, memberId: string, id: string) => Promise<void>;
114
- };
11
+ resolve(guildId: string, resolve: GuildMemberResolvable): Promise<GuildMember | undefined>;
12
+ /**
13
+ * Searches for members in the guild based on the provided query.
14
+ * @param guildId The ID of the guild.
15
+ * @param query The query parameters for searching members.
16
+ * @returns A Promise that resolves to an array of matched members.
17
+ */
18
+ search(guildId: string, query?: RESTGetAPIGuildMembersSearchQuery): Promise<GuildMember[]>;
19
+ /**
20
+ * Unbans a member from the guild.
21
+ * @param guildId The ID of the guild.
22
+ * @param memberId The ID of the member to unban.
23
+ * @param body The request body for unbanning the member.
24
+ * @param reason The reason for unbanning the member.
25
+ */
26
+ unban(guildId: string, memberId: string, body?: RESTPutAPIGuildBanJSONBody, reason?: string): Promise<void>;
27
+ /**
28
+ * Bans a member from the guild.
29
+ * @param guildId The ID of the guild.
30
+ * @param memberId The ID of the member to ban.
31
+ * @param body The request body for banning the member.
32
+ * @param reason The reason for banning the member.
33
+ */
34
+ ban(guildId: string, memberId: string, body?: RESTPutAPIGuildBanJSONBody, reason?: string): Promise<void>;
35
+ /**
36
+ * Kicks a member from the guild.
37
+ * @param guildId The ID of the guild.
38
+ * @param memberId The ID of the member to kick.
39
+ * @param reason The reason for kicking the member.
40
+ */
41
+ kick(guildId: string, memberId: string, reason?: string): Promise<void>;
42
+ /**
43
+ * Edits a member in the guild.
44
+ * @param guildId The ID of the guild.
45
+ * @param memberId The ID of the member to edit.
46
+ * @param body The data to update the member with.
47
+ * @param reason The reason for editing the member.
48
+ * @returns A Promise that resolves to the edited member.
49
+ */
50
+ edit(guildId: string, memberId: string, body: RESTPatchAPIGuildMemberJSONBody, reason?: string): Promise<GuildMember>;
51
+ /**
52
+ * Adds a member to the guild.
53
+ * @param guildId The ID of the guild.
54
+ * @param memberId The ID of the member to add.
55
+ * @param body The request body for adding the member.
56
+ * @returns A Promise that resolves to the added member.
57
+ */
58
+ add(guildId: string, memberId: string, body: RESTPutAPIGuildMemberJSONBody): Promise<GuildMember | undefined>;
59
+ /**
60
+ * Fetches a member from the guild.
61
+ * @param guildId The ID of the guild.
62
+ * @param memberId The ID of the member to fetch.
63
+ * @param force Whether to force fetching the member from the API even if it exists in the cache.
64
+ * @returns A Promise that resolves to the fetched member.
65
+ */
66
+ fetch(guildId: string, memberId: string, force?: boolean): Promise<GuildMember>;
67
+ /**
68
+ * Lists members in the guild based on the provided query.
69
+ * @param guildId The ID of the guild.
70
+ * @param query The query parameters for listing members.
71
+ * @param force Whether to force listing members from the API even if they exist in the cache.
72
+ * @returns A Promise that resolves to an array of listed members.
73
+ */
74
+ list(guildId: string, query?: RESTGetAPIGuildMembersQuery, force?: boolean): Promise<GuildMember[]>;
75
+ /**
76
+ * Adds a role to a guild member.
77
+ * @param guildId The ID of the guild.
78
+ * @param memberId The ID of the member to add the role to.
79
+ * @param id The ID of the role to add.
80
+ */
81
+ addRole(guildId: string, memberId: string, id: string): void;
82
+ /**
83
+ * Removes a role from a guild member.
84
+ * @param guildId The ID of the guild.
85
+ * @param memberId The ID of the member to remove the role from.
86
+ * @param id The ID of the role to remove.
87
+ */
88
+ removeRole(guildId: string, memberId: string, id: string): Promise<never>;
115
89
  }
@@ -6,174 +6,159 @@ const structures_1 = require("../../structures");
6
6
  const base_1 = require("./base");
7
7
  class MemberShorter extends base_1.BaseShorter {
8
8
  /**
9
- * Provides access to member-related functionality in a guild.
9
+ * Resolves a member in the guild based on the provided GuildMemberResolvable.
10
+ * @param guildId The ID of the guild.
11
+ * @param resolve The GuildMemberResolvable to resolve.
12
+ * @returns A Promise that resolves to the resolved member.
10
13
  */
11
- get members() {
12
- return {
13
- /**
14
- * Resolves a member in the guild based on the provided GuildMemberResolvable.
15
- * @param guildId The ID of the guild.
16
- * @param resolve The GuildMemberResolvable to resolve.
17
- * @returns A Promise that resolves to the resolved member.
18
- */
19
- resolve: async (guildId, resolve) => {
20
- if (typeof resolve === 'string') {
21
- const match = resolve.match(__1.FormattingPatterns.User)?.groups;
22
- if (match?.id) {
23
- return this.members.fetch(guildId, match.id);
24
- }
25
- if (resolve.match(/\d{17,20}/)) {
26
- return this.members.fetch(guildId, resolve);
27
- }
28
- return this.members.search(guildId, { query: resolve, limit: 1 }).then(x => x[0]);
29
- }
30
- if (resolve.id) {
31
- return this.client.members.fetch(guildId, resolve.id);
32
- }
33
- return resolve.displayName
34
- ? this.members.search(guildId, { query: resolve.displayName, limit: 1 }).then(x => x[0])
35
- : undefined;
36
- },
37
- /**
38
- * Searches for members in the guild based on the provided query.
39
- * @param guildId The ID of the guild.
40
- * @param query The query parameters for searching members.
41
- * @returns A Promise that resolves to an array of matched members.
42
- */
43
- search: async (guildId, query) => {
44
- const members = await this.client.proxy.guilds(guildId).members.search.get({
45
- query,
46
- });
47
- await this.client.cache.members?.set(members.map(x => [x.user.id, x]), guildId);
48
- return members.map(m => new structures_1.GuildMember(this.client, m, m.user, guildId));
49
- },
50
- /**
51
- * Unbans a member from the guild.
52
- * @param guildId The ID of the guild.
53
- * @param memberId The ID of the member to unban.
54
- * @param body The request body for unbanning the member.
55
- * @param reason The reason for unbanning the member.
56
- */
57
- unban: async (guildId, memberId, body, reason) => {
58
- await this.client.proxy.guilds(guildId).bans(memberId).delete({ reason, body });
59
- },
60
- /**
61
- * Bans a member from the guild.
62
- * @param guildId The ID of the guild.
63
- * @param memberId The ID of the member to ban.
64
- * @param body The request body for banning the member.
65
- * @param reason The reason for banning the member.
66
- */
67
- ban: async (guildId, memberId, body, reason) => {
68
- await this.client.proxy.guilds(guildId).bans(memberId).put({ reason, body });
69
- await this.client.cache.members?.removeIfNI('GuildBans', memberId, guildId);
70
- },
71
- /**
72
- * Kicks a member from the guild.
73
- * @param guildId The ID of the guild.
74
- * @param memberId The ID of the member to kick.
75
- * @param reason The reason for kicking the member.
76
- */
77
- kick: async (guildId, memberId, reason) => {
78
- await this.client.proxy.guilds(guildId).members(memberId).delete({ reason });
79
- await this.client.cache.members?.removeIfNI('GuildMembers', memberId, guildId);
80
- },
81
- /**
82
- * Edits a member in the guild.
83
- * @param guildId The ID of the guild.
84
- * @param memberId The ID of the member to edit.
85
- * @param body The data to update the member with.
86
- * @param reason The reason for editing the member.
87
- * @returns A Promise that resolves to the edited member.
88
- */
89
- edit: async (guildId, memberId, body, reason) => {
90
- const member = await this.client.proxy.guilds(guildId).members(memberId).patch({ body, reason });
91
- await this.client.cache.members?.setIfNI('GuildMembers', memberId, guildId, member);
92
- return new structures_1.GuildMember(this.client, member, member.user, guildId);
93
- },
94
- /**
95
- * Adds a member to the guild.
96
- * @param guildId The ID of the guild.
97
- * @param memberId The ID of the member to add.
98
- * @param body The request body for adding the member.
99
- * @returns A Promise that resolves to the added member.
100
- */
101
- add: async (guildId, memberId, body) => {
102
- const member = await this.client.proxy.guilds(guildId).members(memberId).put({
103
- body,
104
- });
105
- // Thanks dapi-types, fixed
106
- if (!member) {
107
- return;
108
- }
109
- await this.client.cache.members?.setIfNI('GuildMembers', member.user.id, guildId, member);
110
- return new structures_1.GuildMember(this.client, member, member.user, guildId);
111
- },
112
- /**
113
- * Fetches a member from the guild.
114
- * @param guildId The ID of the guild.
115
- * @param memberId The ID of the member to fetch.
116
- * @param force Whether to force fetching the member from the API even if it exists in the cache.
117
- * @returns A Promise that resolves to the fetched member.
118
- */
119
- fetch: async (guildId, memberId, force = false) => {
120
- let member;
121
- if (!force) {
122
- member = await this.client.cache.members?.get(memberId, guildId);
123
- if (member)
124
- return member;
125
- }
126
- member = await this.client.proxy.guilds(guildId).members(memberId).get();
127
- await this.client.cache.members?.set(member.user.id, guildId, member);
128
- return new structures_1.GuildMember(this.client, member, member.user, guildId);
129
- },
130
- /**
131
- * Lists members in the guild based on the provided query.
132
- * @param guildId The ID of the guild.
133
- * @param query The query parameters for listing members.
134
- * @param force Whether to force listing members from the API even if they exist in the cache.
135
- * @returns A Promise that resolves to an array of listed members.
136
- */
137
- list: async (guildId, query, force = false) => {
138
- let members;
139
- if (!force) {
140
- members = (await this.client.cache.members?.values(guildId)) ?? [];
141
- if (members.length)
142
- return members;
143
- }
144
- members = await this.client.proxy.guilds(guildId).members.get({
145
- query,
146
- });
147
- await this.client.cache.members?.set(members.map(x => [x.user.id, x]), guildId);
148
- return members.map(m => new structures_1.GuildMember(this.client, m, m.user, guildId));
149
- },
150
- /**
151
- * Provides methods to add and remove roles from a guild member.
152
- */
153
- roles: this.roles,
154
- };
14
+ async resolve(guildId, resolve) {
15
+ if (typeof resolve === 'string') {
16
+ const match = resolve.match(__1.FormattingPatterns.User)?.groups;
17
+ if (match?.id) {
18
+ return this.fetch(guildId, match.id);
19
+ }
20
+ if (resolve.match(/\d{17,20}/)) {
21
+ return this.fetch(guildId, resolve);
22
+ }
23
+ return this.search(guildId, { query: resolve, limit: 1 }).then(x => x[0]);
24
+ }
25
+ if (resolve.id) {
26
+ return this.client.members.fetch(guildId, resolve.id);
27
+ }
28
+ return resolve.displayName
29
+ ? this.search(guildId, { query: resolve.displayName, limit: 1 }).then(x => x[0])
30
+ : undefined;
155
31
  }
156
- get roles() {
157
- return {
158
- /**
159
- * Adds a role to a guild member.
160
- * @param guildId The ID of the guild.
161
- * @param memberId The ID of the member to add the role to.
162
- * @param id The ID of the role to add.
163
- */
164
- add: async (guildId, memberId, id) => {
165
- await this.client.proxy.guilds(guildId).members(memberId).roles(id).put({});
166
- },
167
- /**
168
- * Removes a role from a guild member.
169
- * @param guildId The ID of the guild.
170
- * @param memberId The ID of the member to remove the role from.
171
- * @param id The ID of the role to remove.
172
- */
173
- remove: async (guildId, memberId, id) => {
174
- await this.client.proxy.guilds(guildId).members(memberId).roles(id).delete();
175
- },
176
- };
32
+ /**
33
+ * Searches for members in the guild based on the provided query.
34
+ * @param guildId The ID of the guild.
35
+ * @param query The query parameters for searching members.
36
+ * @returns A Promise that resolves to an array of matched members.
37
+ */
38
+ async search(guildId, query) {
39
+ const members = await this.client.proxy.guilds(guildId).members.search.get({
40
+ query,
41
+ });
42
+ await this.client.cache.members?.set(members.map(x => [x.user.id, x]), guildId);
43
+ return members.map(m => new structures_1.GuildMember(this.client, m, m.user, guildId));
44
+ }
45
+ /**
46
+ * Unbans a member from the guild.
47
+ * @param guildId The ID of the guild.
48
+ * @param memberId The ID of the member to unban.
49
+ * @param body The request body for unbanning the member.
50
+ * @param reason The reason for unbanning the member.
51
+ */
52
+ async unban(guildId, memberId, body, reason) {
53
+ await this.client.proxy.guilds(guildId).bans(memberId).delete({ reason, body });
54
+ }
55
+ /**
56
+ * Bans a member from the guild.
57
+ * @param guildId The ID of the guild.
58
+ * @param memberId The ID of the member to ban.
59
+ * @param body The request body for banning the member.
60
+ * @param reason The reason for banning the member.
61
+ */
62
+ async ban(guildId, memberId, body, reason) {
63
+ await this.client.proxy.guilds(guildId).bans(memberId).put({ reason, body });
64
+ await this.client.cache.members?.removeIfNI('GuildBans', memberId, guildId);
65
+ }
66
+ /**
67
+ * Kicks a member from the guild.
68
+ * @param guildId The ID of the guild.
69
+ * @param memberId The ID of the member to kick.
70
+ * @param reason The reason for kicking the member.
71
+ */
72
+ async kick(guildId, memberId, reason) {
73
+ await this.client.proxy.guilds(guildId).members(memberId).delete({ reason });
74
+ await this.client.cache.members?.removeIfNI('GuildMembers', memberId, guildId);
75
+ }
76
+ /**
77
+ * Edits a member in the guild.
78
+ * @param guildId The ID of the guild.
79
+ * @param memberId The ID of the member to edit.
80
+ * @param body The data to update the member with.
81
+ * @param reason The reason for editing the member.
82
+ * @returns A Promise that resolves to the edited member.
83
+ */
84
+ async edit(guildId, memberId, body, reason) {
85
+ const member = await this.client.proxy.guilds(guildId).members(memberId).patch({ body, reason });
86
+ await this.client.cache.members?.setIfNI('GuildMembers', memberId, guildId, member);
87
+ return new structures_1.GuildMember(this.client, member, member.user, guildId);
88
+ }
89
+ /**
90
+ * Adds a member to the guild.
91
+ * @param guildId The ID of the guild.
92
+ * @param memberId The ID of the member to add.
93
+ * @param body The request body for adding the member.
94
+ * @returns A Promise that resolves to the added member.
95
+ */
96
+ async add(guildId, memberId, body) {
97
+ const member = await this.client.proxy.guilds(guildId).members(memberId).put({
98
+ body,
99
+ });
100
+ // Thanks dapi-types, fixed
101
+ if (!member) {
102
+ return;
103
+ }
104
+ await this.client.cache.members?.setIfNI('GuildMembers', member.user.id, guildId, member);
105
+ return new structures_1.GuildMember(this.client, member, member.user, guildId);
106
+ }
107
+ /**
108
+ * Fetches a member from the guild.
109
+ * @param guildId The ID of the guild.
110
+ * @param memberId The ID of the member to fetch.
111
+ * @param force Whether to force fetching the member from the API even if it exists in the cache.
112
+ * @returns A Promise that resolves to the fetched member.
113
+ */
114
+ async fetch(guildId, memberId, force = false) {
115
+ let member;
116
+ if (!force) {
117
+ member = await this.client.cache.members?.get(memberId, guildId);
118
+ if (member)
119
+ return member;
120
+ }
121
+ member = await this.client.proxy.guilds(guildId).members(memberId).get();
122
+ await this.client.cache.members?.set(member.user.id, guildId, member);
123
+ return new structures_1.GuildMember(this.client, member, member.user, guildId);
124
+ }
125
+ /**
126
+ * Lists members in the guild based on the provided query.
127
+ * @param guildId The ID of the guild.
128
+ * @param query The query parameters for listing members.
129
+ * @param force Whether to force listing members from the API even if they exist in the cache.
130
+ * @returns A Promise that resolves to an array of listed members.
131
+ */
132
+ async list(guildId, query, force = false) {
133
+ let members;
134
+ if (!force) {
135
+ members = (await this.client.cache.members?.values(guildId)) ?? [];
136
+ if (members.length)
137
+ return members;
138
+ }
139
+ members = await this.client.proxy.guilds(guildId).members.get({
140
+ query,
141
+ });
142
+ await this.client.cache.members?.set(members.map(x => [x.user.id, x]), guildId);
143
+ return members.map(m => new structures_1.GuildMember(this.client, m, m.user, guildId));
144
+ }
145
+ /**
146
+ * Adds a role to a guild member.
147
+ * @param guildId The ID of the guild.
148
+ * @param memberId The ID of the member to add the role to.
149
+ * @param id The ID of the role to add.
150
+ */
151
+ addRole(guildId, memberId, id) {
152
+ this.client.proxy.guilds(guildId).members(memberId).roles(id).put({});
153
+ }
154
+ /**
155
+ * Removes a role from a guild member.
156
+ * @param guildId The ID of the guild.
157
+ * @param memberId The ID of the member to remove the role from.
158
+ * @param id The ID of the role to remove.
159
+ */
160
+ removeRole(guildId, memberId, id) {
161
+ return this.client.proxy.guilds(guildId).members(memberId).roles(id).delete();
177
162
  }
178
163
  }
179
164
  exports.MemberShorter = MemberShorter;
@@ -1,27 +1,15 @@
1
- import type { RESTGetAPIChannelMessageReactionUsersQuery } from 'discord-api-types/v10';
2
- import { Message, User } from '../../structures';
3
- import type { EmojiResolvable } from '../types/resolvables';
1
+ import type { RESTPostAPIChannelMessagesThreadsJSONBody } from 'discord-api-types/v10';
2
+ import { Message, ThreadChannel } from '../../structures';
4
3
  import type { MessageCreateBodyRequest, MessageUpdateBodyRequest } from '../types/write';
5
4
  import { BaseShorter } from './base';
6
5
  export declare class MessageShorter extends BaseShorter {
7
- get messages(): {
8
- write: (channelId: string, { files, ...body }: MessageCreateBodyRequest) => Promise<Message>;
9
- edit: (messageId: string, channelId: string, { files, ...body }: MessageUpdateBodyRequest) => Promise<Message>;
10
- crosspost: (messageId: string, channelId: string, reason?: string) => Promise<Message>;
11
- delete: (messageId: string, channelId: string, reason?: string) => Promise<void>;
12
- fetch: (messageId: string, channelId: string) => Promise<Message>;
13
- purge: (messages: string[], channelId: string, reason?: string) => Promise<never>;
14
- reactions: {
15
- add: (messageId: string, channelId: string, emoji: EmojiResolvable) => Promise<never>;
16
- delete: (messageId: string, channelId: string, emoji: EmojiResolvable, userId?: string) => Promise<never>;
17
- fetch: (messageId: string, channelId: string, emoji: EmojiResolvable, query?: RESTGetAPIChannelMessageReactionUsersQuery | undefined) => Promise<User[]>;
18
- purge: (messageId: string, channelId: string, emoji?: EmojiResolvable | undefined) => Promise<never>;
19
- };
20
- };
21
- get reactions(): {
22
- add: (messageId: string, channelId: string, emoji: EmojiResolvable) => Promise<never>;
23
- delete: (messageId: string, channelId: string, emoji: EmojiResolvable, userId?: string) => Promise<never>;
24
- fetch: (messageId: string, channelId: string, emoji: EmojiResolvable, query?: RESTGetAPIChannelMessageReactionUsersQuery) => Promise<User[]>;
25
- purge: (messageId: string, channelId: string, emoji?: EmojiResolvable) => Promise<never>;
26
- };
6
+ write(channelId: string, { files, ...body }: MessageCreateBodyRequest): Promise<Message>;
7
+ edit(messageId: string, channelId: string, { files, ...body }: MessageUpdateBodyRequest): Promise<Message>;
8
+ crosspost(messageId: string, channelId: string, reason?: string): Promise<Message>;
9
+ delete(messageId: string, channelId: string, reason?: string): Promise<void>;
10
+ fetch(messageId: string, channelId: string): Promise<Message>;
11
+ purge(messages: string[], channelId: string, reason?: string): Promise<never>;
12
+ thread(channelId: string, messageId: string, options: RESTPostAPIChannelMessagesThreadsJSONBody & {
13
+ reason?: string;
14
+ }): Promise<ThreadChannel>;
27
15
  }