seyfert 1.0.1 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) 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/types.d.ts +23 -23
  11. package/lib/cache/adapters/workeradapter.d.ts +4 -4
  12. package/lib/cache/adapters/workeradapter.js +10 -5
  13. package/lib/cache/index.d.ts +4 -5
  14. package/lib/cache/index.js +4 -3
  15. package/lib/cache/resources/default/base.d.ts +11 -10
  16. package/lib/cache/resources/default/guild-based.d.ts +8 -7
  17. package/lib/cache/resources/default/guild-based.js +8 -7
  18. package/lib/cache/resources/default/guild-related.d.ts +10 -9
  19. package/lib/cache/resources/default/guild-related.js +3 -2
  20. package/lib/cache/resources/guilds.js +2 -1
  21. package/lib/cache/resources/overwrites.d.ts +1 -1
  22. package/lib/cache/resources/overwrites.js +7 -1
  23. package/lib/client/base.d.ts +33 -179
  24. package/lib/client/base.js +56 -21
  25. package/lib/client/client.d.ts +10 -3
  26. package/lib/client/client.js +23 -8
  27. package/lib/client/oninteractioncreate.js +9 -9
  28. package/lib/client/onmessagecreate.js +192 -153
  29. package/lib/client/workerclient.d.ts +9 -3
  30. package/lib/client/workerclient.js +50 -23
  31. package/lib/collection.js +2 -2
  32. package/lib/commands/applications/chat.d.ts +16 -8
  33. package/lib/commands/applications/chat.js +20 -13
  34. package/lib/commands/applications/chatcontext.d.ts +6 -4
  35. package/lib/commands/applications/chatcontext.js +6 -1
  36. package/lib/commands/applications/menu.d.ts +5 -1
  37. package/lib/commands/applications/menu.js +11 -5
  38. package/lib/commands/applications/menucontext.d.ts +5 -3
  39. package/lib/commands/applications/menucontext.js +7 -2
  40. package/lib/commands/applications/options.d.ts +1 -2
  41. package/lib/commands/applications/shared.d.ts +5 -4
  42. package/lib/commands/decorators.d.ts +18 -6
  43. package/lib/commands/decorators.js +18 -8
  44. package/lib/commands/handler.d.ts +11 -5
  45. package/lib/commands/handler.js +46 -37
  46. package/lib/commands/optionresolver.d.ts +11 -4
  47. package/lib/commands/optionresolver.js +6 -4
  48. package/lib/common/index.d.ts +7 -0
  49. package/lib/common/index.js +7 -0
  50. package/lib/common/it/utils.d.ts +1 -0
  51. package/lib/common/it/utils.js +4 -1
  52. package/lib/common/shorters/channels.d.ts +67 -129
  53. package/lib/common/shorters/channels.js +119 -135
  54. package/lib/common/shorters/emojis.d.ts +47 -0
  55. package/lib/common/shorters/emojis.js +80 -0
  56. package/lib/common/shorters/guilds.d.ts +22 -249
  57. package/lib/common/shorters/guilds.js +51 -140
  58. package/lib/common/shorters/members.d.ts +82 -108
  59. package/lib/common/shorters/members.js +151 -166
  60. package/lib/common/shorters/messages.d.ts +11 -23
  61. package/lib/common/shorters/messages.js +58 -104
  62. package/lib/common/shorters/reactions.d.ts +10 -0
  63. package/lib/common/shorters/reactions.js +45 -0
  64. package/lib/common/shorters/roles.d.ts +39 -7
  65. package/lib/common/shorters/roles.js +74 -42
  66. package/lib/common/shorters/templates.d.ts +6 -8
  67. package/lib/common/shorters/templates.js +17 -21
  68. package/lib/common/shorters/users.d.ts +4 -6
  69. package/lib/common/shorters/users.js +29 -33
  70. package/lib/common/shorters/webhook.d.ts +62 -26
  71. package/lib/common/shorters/webhook.js +113 -58
  72. package/lib/common/types/options.d.ts +2 -2
  73. package/lib/common/types/util.d.ts +3 -0
  74. package/lib/components/handler.d.ts +28 -9
  75. package/lib/components/handler.js +28 -11
  76. package/lib/events/handler.d.ts +10 -2
  77. package/lib/events/handler.js +6 -8
  78. package/lib/index.d.ts +4 -2
  79. package/lib/index.js +1 -1
  80. package/lib/langs/handler.d.ts +8 -0
  81. package/lib/langs/handler.js +8 -2
  82. package/lib/structures/AutoModerationRule.d.ts +2 -2
  83. package/lib/structures/ClientUser.d.ts +2 -2
  84. package/lib/structures/Guild.d.ts +2 -2
  85. package/lib/structures/GuildEmoji.d.ts +4 -4
  86. package/lib/structures/GuildEmoji.js +7 -7
  87. package/lib/structures/GuildMember.d.ts +7 -6
  88. package/lib/structures/GuildMember.js +5 -2
  89. package/lib/structures/GuildPreview.d.ts +2 -2
  90. package/lib/structures/GuildRole.d.ts +2 -2
  91. package/lib/structures/GuildTemplate.d.ts +2 -2
  92. package/lib/structures/Interaction.d.ts +9 -10
  93. package/lib/structures/Interaction.js +2 -2
  94. package/lib/structures/Message.d.ts +8 -7
  95. package/lib/structures/Message.js +7 -4
  96. package/lib/structures/Sticker.d.ts +2 -2
  97. package/lib/structures/User.d.ts +1 -0
  98. package/lib/structures/User.js +5 -0
  99. package/lib/structures/Webhook.d.ts +2 -2
  100. package/lib/structures/Webhook.js +3 -3
  101. package/lib/structures/channels.d.ts +21 -22
  102. package/lib/structures/channels.js +13 -25
  103. package/lib/structures/extra/Base.d.ts +1 -2
  104. package/lib/structures/extra/DiscordBase.d.ts +2 -2
  105. package/lib/websocket/constants/index.js +1 -0
  106. package/lib/websocket/discord/shard.js +4 -2
  107. package/lib/websocket/discord/sharder.d.ts +3 -0
  108. package/lib/websocket/discord/sharder.js +12 -5
  109. package/lib/websocket/discord/shared.d.ts +1 -0
  110. package/lib/websocket/discord/worker.d.ts +2 -1
  111. package/lib/websocket/discord/workermanager.d.ts +8 -3
  112. package/lib/websocket/discord/workermanager.js +78 -30
  113. package/package.json +8 -6
@@ -3,113 +3,67 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MessageShorter = void 0;
4
4
  const builders_1 = require("../../builders");
5
5
  const structures_1 = require("../../structures");
6
- const functions_1 = require("../../structures/extra/functions");
7
6
  const base_1 = require("./base");
8
7
  class MessageShorter extends base_1.BaseShorter {
9
- get messages() {
10
- return {
11
- write: async (channelId, { files, ...body }) => {
12
- const parsedFiles = files ? await (0, builders_1.resolveFiles)(files) : [];
13
- const transformedBody = structures_1.MessagesMethods.transformMessageBody(body);
14
- return this.client.proxy
15
- .channels(channelId)
16
- .messages.post({
17
- body: transformedBody,
18
- files: parsedFiles,
19
- })
20
- .then(message => {
21
- return new structures_1.Message(this.client, message);
22
- });
23
- },
24
- edit: async (messageId, channelId, { files, ...body }) => {
25
- const parsedFiles = files ? await (0, builders_1.resolveFiles)(files) : [];
26
- return this.client.proxy
27
- .channels(channelId)
28
- .messages(messageId)
29
- .patch({
30
- body: structures_1.MessagesMethods.transformMessageBody(body),
31
- files: parsedFiles,
32
- })
33
- .then(message => {
34
- return new structures_1.Message(this.client, message);
35
- });
36
- },
37
- crosspost: (messageId, channelId, reason) => {
38
- return this.client.proxy
39
- .channels(channelId)
40
- .messages(messageId)
41
- .crosspost.post({ reason })
42
- .then(m => new structures_1.Message(this.client, m));
43
- },
44
- delete: (messageId, channelId, reason) => {
45
- return this.client.proxy
46
- .channels(channelId)
47
- .messages(messageId)
48
- .delete({ reason })
49
- .then(() => {
50
- return this.client.components.onMessageDelete(messageId);
51
- });
52
- },
53
- fetch: async (messageId, channelId) => {
54
- return this.client.proxy
55
- .channels(channelId)
56
- .messages(messageId)
57
- .get()
58
- .then(x => new structures_1.Message(this.client, x));
59
- },
60
- purge: (messages, channelId, reason) => {
61
- return this.client.proxy.channels(channelId).messages['bulk-delete'].post({ body: { messages }, reason });
62
- },
63
- reactions: this.reactions,
64
- };
8
+ async write(channelId, { files, ...body }) {
9
+ const parsedFiles = files ? await (0, builders_1.resolveFiles)(files) : [];
10
+ const transformedBody = structures_1.MessagesMethods.transformMessageBody(body);
11
+ return this.client.proxy
12
+ .channels(channelId)
13
+ .messages.post({
14
+ body: transformedBody,
15
+ files: parsedFiles,
16
+ })
17
+ .then(message => {
18
+ return new structures_1.Message(this.client, message);
19
+ });
65
20
  }
66
- get reactions() {
67
- return {
68
- add: async (messageId, channelId, emoji) => {
69
- const rawEmoji = await (0, functions_1.resolveEmoji)(emoji, this.client.cache);
70
- if (!rawEmoji) {
71
- throw new Error('Emoji no resolvable');
72
- }
73
- return this.client.proxy
74
- .channels(channelId)
75
- .messages(messageId)
76
- .reactions((0, functions_1.encodeEmoji)(rawEmoji))('@me')
77
- .put({});
78
- },
79
- delete: async (messageId, channelId, emoji, userId = '@me') => {
80
- const rawEmoji = await (0, functions_1.resolveEmoji)(emoji, this.client.cache);
81
- if (!rawEmoji) {
82
- throw new Error('Emoji no resolvable');
83
- }
84
- return this.client.proxy
85
- .channels(channelId)
86
- .messages(messageId)
87
- .reactions((0, functions_1.encodeEmoji)(rawEmoji))(userId)
88
- .delete();
89
- },
90
- fetch: async (messageId, channelId, emoji, query) => {
91
- const rawEmoji = await (0, functions_1.resolveEmoji)(emoji, this.client.cache);
92
- if (!rawEmoji) {
93
- throw new Error('Emoji no resolvable');
94
- }
95
- return this.client.proxy
96
- .channels(channelId)
97
- .messages(messageId)
98
- .reactions((0, functions_1.encodeEmoji)(rawEmoji))
99
- .get({ query })
100
- .then(u => u.map(user => new structures_1.User(this.client, user)));
101
- },
102
- purge: async (messageId, channelId, emoji) => {
103
- if (!emoji) {
104
- return this.client.proxy.channels(channelId).messages(messageId).reactions.delete();
105
- }
106
- const rawEmoji = await (0, functions_1.resolveEmoji)(emoji, this.client.cache);
107
- if (!rawEmoji) {
108
- throw new Error('Emoji no resolvable');
109
- }
110
- return this.client.proxy.channels(channelId).messages(messageId).reactions((0, functions_1.encodeEmoji)(rawEmoji)).delete();
111
- },
112
- };
21
+ async edit(messageId, channelId, { files, ...body }) {
22
+ const parsedFiles = files ? await (0, builders_1.resolveFiles)(files) : [];
23
+ return this.client.proxy
24
+ .channels(channelId)
25
+ .messages(messageId)
26
+ .patch({
27
+ body: structures_1.MessagesMethods.transformMessageBody(body),
28
+ files: parsedFiles,
29
+ })
30
+ .then(message => {
31
+ return new structures_1.Message(this.client, message);
32
+ });
33
+ }
34
+ crosspost(messageId, channelId, reason) {
35
+ return this.client.proxy
36
+ .channels(channelId)
37
+ .messages(messageId)
38
+ .crosspost.post({ reason })
39
+ .then(m => new structures_1.Message(this.client, m));
40
+ }
41
+ delete(messageId, channelId, reason) {
42
+ return this.client.proxy
43
+ .channels(channelId)
44
+ .messages(messageId)
45
+ .delete({ reason })
46
+ .then(() => {
47
+ return this.client.components?.onMessageDelete(messageId);
48
+ });
49
+ }
50
+ fetch(messageId, channelId) {
51
+ return this.client.proxy
52
+ .channels(channelId)
53
+ .messages(messageId)
54
+ .get()
55
+ .then(x => new structures_1.Message(this.client, x));
56
+ }
57
+ purge(messages, channelId, reason) {
58
+ return this.client.proxy.channels(channelId).messages['bulk-delete'].post({ body: { messages }, reason });
59
+ }
60
+ thread(channelId, messageId, options) {
61
+ const { reason, ...body } = options;
62
+ return this.client.proxy
63
+ .channels(channelId)
64
+ .messages(messageId)
65
+ .threads.post({ body, reason })
66
+ .then(x => new structures_1.ThreadChannel(this.client, x));
113
67
  }
114
68
  }
115
69
  exports.MessageShorter = MessageShorter;
@@ -0,0 +1,10 @@
1
+ import type { RESTGetAPIChannelMessageReactionUsersQuery } from 'discord-api-types/v10';
2
+ import { User } from '../../structures';
3
+ import type { EmojiResolvable } from '../types/resolvables';
4
+ import { BaseShorter } from './base';
5
+ export declare class ReactionShorter extends BaseShorter {
6
+ add(messageId: string, channelId: string, emoji: EmojiResolvable): Promise<void>;
7
+ delete(messageId: string, channelId: string, emoji: EmojiResolvable, userId?: string): Promise<void>;
8
+ fetch(messageId: string, channelId: string, emoji: EmojiResolvable, query?: RESTGetAPIChannelMessageReactionUsersQuery): Promise<User[]>;
9
+ purge(messageId: string, channelId: string, emoji?: EmojiResolvable): Promise<void>;
10
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReactionShorter = void 0;
4
+ const structures_1 = require("../../structures");
5
+ const functions_1 = require("../../structures/extra/functions");
6
+ const base_1 = require("./base");
7
+ class ReactionShorter extends base_1.BaseShorter {
8
+ async add(messageId, channelId, emoji) {
9
+ const rawEmoji = await (0, functions_1.resolveEmoji)(emoji, this.client.cache);
10
+ if (!rawEmoji) {
11
+ throw new Error('Emoji no resolvable');
12
+ }
13
+ return this.client.proxy.channels(channelId).messages(messageId).reactions((0, functions_1.encodeEmoji)(rawEmoji))('@me').put({});
14
+ }
15
+ async delete(messageId, channelId, emoji, userId = '@me') {
16
+ const rawEmoji = await (0, functions_1.resolveEmoji)(emoji, this.client.cache);
17
+ if (!rawEmoji) {
18
+ throw new Error('Emoji no resolvable');
19
+ }
20
+ return this.client.proxy.channels(channelId).messages(messageId).reactions((0, functions_1.encodeEmoji)(rawEmoji))(userId).delete();
21
+ }
22
+ async fetch(messageId, channelId, emoji, query) {
23
+ const rawEmoji = await (0, functions_1.resolveEmoji)(emoji, this.client.cache);
24
+ if (!rawEmoji) {
25
+ throw new Error('Emoji no resolvable');
26
+ }
27
+ return this.client.proxy
28
+ .channels(channelId)
29
+ .messages(messageId)
30
+ .reactions((0, functions_1.encodeEmoji)(rawEmoji))
31
+ .get({ query })
32
+ .then(u => u.map(user => new structures_1.User(this.client, user)));
33
+ }
34
+ async purge(messageId, channelId, emoji) {
35
+ if (!emoji) {
36
+ return this.client.proxy.channels(channelId).messages(messageId).reactions.delete();
37
+ }
38
+ const rawEmoji = await (0, functions_1.resolveEmoji)(emoji, this.client.cache);
39
+ if (!rawEmoji) {
40
+ throw new Error('Emoji no resolvable');
41
+ }
42
+ return this.client.proxy.channels(channelId).messages(messageId).reactions((0, functions_1.encodeEmoji)(rawEmoji)).delete();
43
+ }
44
+ }
45
+ exports.ReactionShorter = ReactionShorter;
@@ -2,11 +2,43 @@ import type { RESTPatchAPIGuildRoleJSONBody, RESTPatchAPIGuildRolePositionsJSONB
2
2
  import { GuildRole } from '../../structures';
3
3
  import { BaseShorter } from './base';
4
4
  export declare class RoleShorter extends BaseShorter {
5
- get roles(): {
6
- create: (guildId: string, body: RESTPostAPIGuildRoleJSONBody, reason?: string) => Promise<any>;
7
- list: (guildId: string, force?: boolean) => Promise<GuildRole[]>;
8
- edit: (guildId: string, roleId: string, body: RESTPatchAPIGuildRoleJSONBody, reason?: string) => Promise<any>;
9
- delete: (guildId: string, roleId: string, reason?: string) => Promise<void | undefined>;
10
- editPositions: (guildId: string, body: RESTPatchAPIGuildRolePositionsJSONBody) => Promise<GuildRole[]>;
11
- };
5
+ /**
6
+ * Creates a new role in the guild.
7
+ * @param guildId The ID of the guild.
8
+ * @param body The data for creating the role.
9
+ * @param reason The reason for creating the role.
10
+ * @returns A Promise that resolves when the role is created.
11
+ */
12
+ create(guildId: string, body: RESTPostAPIGuildRoleJSONBody, reason?: string): Promise<any>;
13
+ /**
14
+ * Retrieves a list of roles in the guild.
15
+ * @param guildId The ID of the guild.
16
+ * @param force Whether to force fetching roles from the API even if they exist in the cache.
17
+ * @returns A Promise that resolves to an array of roles.
18
+ */
19
+ list(guildId: string, force?: boolean): Promise<GuildRole[]>;
20
+ /**
21
+ * Edits a role in the guild.
22
+ * @param guildId The ID of the guild.
23
+ * @param roleId The ID of the role to edit.
24
+ * @param body The data to update the role with.
25
+ * @param reason The reason for editing the role.
26
+ * @returns A Promise that resolves when the role is edited.
27
+ */
28
+ edit(guildId: string, roleId: string, body: RESTPatchAPIGuildRoleJSONBody, reason?: string): Promise<any>;
29
+ /**
30
+ * Deletes a role from the guild.
31
+ * @param guildId The ID of the guild.
32
+ * @param roleId The ID of the role to delete.
33
+ * @param reason The reason for deleting the role.
34
+ * @returns A Promise that resolves when the role is deleted.
35
+ */
36
+ delete(guildId: string, roleId: string, reason?: string): Promise<void | undefined>;
37
+ /**
38
+ * Edits the positions of roles in the guild.
39
+ * @param guildId The ID of the guild.
40
+ * @param body The data to update the positions of roles with.
41
+ * @returns A Promise that resolves to an array of edited roles.
42
+ */
43
+ editPositions(guildId: string, body: RESTPatchAPIGuildRolePositionsJSONBody): Promise<GuildRole[]>;
12
44
  }
@@ -4,48 +4,80 @@ exports.RoleShorter = void 0;
4
4
  const structures_1 = require("../../structures");
5
5
  const base_1 = require("./base");
6
6
  class RoleShorter extends base_1.BaseShorter {
7
- get roles() {
8
- return {
9
- create: (guildId, body, reason) => this.client.proxy
10
- .guilds(guildId)
11
- .roles.post({ body, reason })
12
- .then(res => this.client.cache.roles?.setIfNI('Guilds', res.id, guildId, res)),
13
- list: async (guildId, force = false) => {
14
- let roles = [];
15
- if (!force) {
16
- const cachedRoles = (await this.client.cache.roles?.values(guildId)) ?? [];
17
- if (cachedRoles.length) {
18
- return cachedRoles;
19
- }
20
- }
21
- roles = await this.client.proxy.guilds(guildId).roles.get();
22
- await this.client.cache.roles?.set(roles.map(r => [r.id, r]), guildId);
23
- return roles.map(r => new structures_1.GuildRole(this.client, r, guildId));
24
- },
25
- edit: (guildId, roleId, body, reason) => {
26
- return this.client.proxy
27
- .guilds(guildId)
28
- .roles(roleId)
29
- .patch({ body, reason })
30
- .then(res => this.client.cache.roles?.setIfNI('Guilds', roleId, guildId, res));
31
- },
32
- delete: (guildId, roleId, reason) => {
33
- return this.client.proxy
34
- .guilds(guildId)
35
- .roles(roleId)
36
- .delete({ reason })
37
- .then(() => this.client.cache.roles?.removeIfNI('Guilds', roleId, guildId));
38
- },
39
- editPositions: async (guildId, body) => {
40
- const roles = await this.client.proxy.guilds(guildId).roles.patch({
41
- body,
42
- });
43
- if (!this.client.cache.hasRolesIntent) {
44
- await this.client.cache.roles?.set(roles.map(x => [x.id, x]), guildId);
45
- }
46
- return roles.map(x => new structures_1.GuildRole(this.client, x, guildId));
47
- },
48
- };
7
+ /**
8
+ * Creates a new role in the guild.
9
+ * @param guildId The ID of the guild.
10
+ * @param body The data for creating the role.
11
+ * @param reason The reason for creating the role.
12
+ * @returns A Promise that resolves when the role is created.
13
+ */
14
+ create(guildId, body, reason) {
15
+ return this.client.proxy
16
+ .guilds(guildId)
17
+ .roles.post({ body, reason })
18
+ .then(res => this.client.cache.roles?.setIfNI('Guilds', res.id, guildId, res));
19
+ }
20
+ /**
21
+ * Retrieves a list of roles in the guild.
22
+ * @param guildId The ID of the guild.
23
+ * @param force Whether to force fetching roles from the API even if they exist in the cache.
24
+ * @returns A Promise that resolves to an array of roles.
25
+ */
26
+ async list(guildId, force = false) {
27
+ let roles = [];
28
+ if (!force) {
29
+ const cachedRoles = (await this.client.cache.roles?.values(guildId)) ?? [];
30
+ if (cachedRoles.length) {
31
+ return cachedRoles;
32
+ }
33
+ }
34
+ roles = await this.client.proxy.guilds(guildId).roles.get();
35
+ await this.client.cache.roles?.set(roles.map(r => [r.id, r]), guildId);
36
+ return roles.map(r => new structures_1.GuildRole(this.client, r, guildId));
37
+ }
38
+ /**
39
+ * Edits a role in the guild.
40
+ * @param guildId The ID of the guild.
41
+ * @param roleId The ID of the role to edit.
42
+ * @param body The data to update the role with.
43
+ * @param reason The reason for editing the role.
44
+ * @returns A Promise that resolves when the role is edited.
45
+ */
46
+ edit(guildId, roleId, body, reason) {
47
+ return this.client.proxy
48
+ .guilds(guildId)
49
+ .roles(roleId)
50
+ .patch({ body, reason })
51
+ .then(res => this.client.cache.roles?.setIfNI('Guilds', roleId, guildId, res));
52
+ }
53
+ /**
54
+ * Deletes a role from the guild.
55
+ * @param guildId The ID of the guild.
56
+ * @param roleId The ID of the role to delete.
57
+ * @param reason The reason for deleting the role.
58
+ * @returns A Promise that resolves when the role is deleted.
59
+ */
60
+ delete(guildId, roleId, reason) {
61
+ return this.client.proxy
62
+ .guilds(guildId)
63
+ .roles(roleId)
64
+ .delete({ reason })
65
+ .then(() => this.client.cache.roles?.removeIfNI('Guilds', roleId, guildId));
66
+ }
67
+ /**
68
+ * Edits the positions of roles in the guild.
69
+ * @param guildId The ID of the guild.
70
+ * @param body The data to update the positions of roles with.
71
+ * @returns A Promise that resolves to an array of edited roles.
72
+ */
73
+ async editPositions(guildId, body) {
74
+ const roles = await this.client.proxy.guilds(guildId).roles.patch({
75
+ body,
76
+ });
77
+ if (!this.client.cache.hasRolesIntent) {
78
+ await this.client.cache.roles?.set(roles.map(x => [x.id, x]), guildId);
79
+ }
80
+ return roles.map(x => new structures_1.GuildRole(this.client, x, guildId));
49
81
  }
50
82
  }
51
83
  exports.RoleShorter = RoleShorter;
@@ -1,12 +1,10 @@
1
1
  import type { RESTPatchAPIGuildTemplateJSONBody, RESTPostAPIGuildTemplatesJSONBody } from 'discord-api-types/v10';
2
2
  import { BaseShorter } from './base';
3
3
  export declare class TemplateShorter extends BaseShorter {
4
- get templates(): {
5
- fetch: (code: string) => Promise<import("discord-api-types/v10").APITemplate>;
6
- list: (guildId: string) => Promise<import("discord-api-types/v10").RESTGetAPIGuildTemplatesResult>;
7
- create: (guildId: string, body: RESTPostAPIGuildTemplatesJSONBody) => Promise<import("discord-api-types/v10").APITemplate>;
8
- sync: (guildId: string, code: string) => Promise<import("discord-api-types/v10").APITemplate>;
9
- edit: (guildId: string, code: string, body: RESTPatchAPIGuildTemplateJSONBody) => Promise<import("discord-api-types/v10").APITemplate>;
10
- delete: (guildId: string, code: string) => Promise<import("discord-api-types/v10").APITemplate>;
11
- };
4
+ fetch(code: string): Promise<import("discord-api-types/v10").APITemplate>;
5
+ list(guildId: string): Promise<import("discord-api-types/v10").RESTGetAPIGuildTemplatesResult>;
6
+ create(guildId: string, body: RESTPostAPIGuildTemplatesJSONBody): Promise<import("discord-api-types/v10").APITemplate>;
7
+ sync(guildId: string, code: string): Promise<import("discord-api-types/v10").APITemplate>;
8
+ edit(guildId: string, code: string, body: RESTPatchAPIGuildTemplateJSONBody): Promise<import("discord-api-types/v10").APITemplate>;
9
+ delete(guildId: string, code: string): Promise<import("discord-api-types/v10").APITemplate>;
12
10
  }
@@ -3,27 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TemplateShorter = void 0;
4
4
  const base_1 = require("./base");
5
5
  class TemplateShorter extends base_1.BaseShorter {
6
- get templates() {
7
- return {
8
- fetch: (code) => {
9
- return this.client.proxy.guilds.templates(code).get();
10
- },
11
- list: (guildId) => {
12
- return this.client.proxy.guilds(guildId).templates.get();
13
- },
14
- create: (guildId, body) => {
15
- return this.client.proxy.guilds(guildId).templates.post({ body });
16
- },
17
- sync: (guildId, code) => {
18
- return this.client.proxy.guilds(guildId).templates(code).put({});
19
- },
20
- edit: (guildId, code, body) => {
21
- return this.client.proxy.guilds(guildId).templates(code).patch({ body });
22
- },
23
- delete: (guildId, code) => {
24
- return this.client.proxy.guilds(guildId).templates(code).delete();
25
- },
26
- };
6
+ fetch(code) {
7
+ return this.client.proxy.guilds.templates(code).get();
8
+ }
9
+ list(guildId) {
10
+ return this.client.proxy.guilds(guildId).templates.get();
11
+ }
12
+ create(guildId, body) {
13
+ return this.client.proxy.guilds(guildId).templates.post({ body });
14
+ }
15
+ sync(guildId, code) {
16
+ return this.client.proxy.guilds(guildId).templates(code).put({});
17
+ }
18
+ edit(guildId, code, body) {
19
+ return this.client.proxy.guilds(guildId).templates(code).patch({ body });
20
+ }
21
+ delete(guildId, code) {
22
+ return this.client.proxy.guilds(guildId).templates(code).delete();
27
23
  }
28
24
  }
29
25
  exports.TemplateShorter = TemplateShorter;
@@ -2,10 +2,8 @@ import { DMChannel, User } from '../../structures';
2
2
  import type { MessageCreateBodyRequest } from '../types/write';
3
3
  import { BaseShorter } from './base';
4
4
  export declare class UsersShorter extends BaseShorter {
5
- get users(): {
6
- createDM: (userId: string, force?: boolean) => Promise<DMChannel>;
7
- deleteDM: (userId: string, reason?: string) => Promise<DMChannel>;
8
- fetch: (userId: string, force?: boolean) => Promise<User>;
9
- write: (userId: string, body: MessageCreateBodyRequest) => Promise<import("../../structures").Message>;
10
- };
5
+ createDM(userId: string, force?: boolean): Promise<DMChannel>;
6
+ deleteDM(userId: string, reason?: string): Promise<DMChannel>;
7
+ fetch(userId: string, force?: boolean): Promise<User>;
8
+ write(userId: string, body: MessageCreateBodyRequest): Promise<import("../../structures").Message>;
11
9
  }
@@ -4,39 +4,35 @@ exports.UsersShorter = void 0;
4
4
  const structures_1 = require("../../structures");
5
5
  const base_1 = require("./base");
6
6
  class UsersShorter extends base_1.BaseShorter {
7
- get users() {
8
- return {
9
- createDM: async (userId, force = false) => {
10
- if (!force) {
11
- const dm = await this.client.cache.channels?.get(userId);
12
- if (dm)
13
- return dm;
14
- }
15
- const data = await this.client.proxy.users('@me').channels.post({
16
- body: { recipient_id: userId },
17
- });
18
- await this.client.cache.channels?.set(userId, '@me', data);
19
- return new structures_1.DMChannel(this.client, data);
20
- },
21
- deleteDM: async (userId, reason) => {
22
- const res = await this.client.proxy.channels(userId).delete({ reason });
23
- await this.client.cache.channels?.removeIfNI(structures_1.BaseChannel.__intent__('@me'), res.id, '@me');
24
- return new structures_1.DMChannel(this.client, res);
25
- },
26
- fetch: async (userId, force = false) => {
27
- if (!force) {
28
- const user = await this.client.cache.users?.get(userId);
29
- if (user)
30
- return user;
31
- }
32
- const data = await this.client.proxy.users(userId).get();
33
- await this.client.cache.users?.patch(userId, data);
34
- return new structures_1.User(this.client, data);
35
- },
36
- write: async (userId, body) => {
37
- return (await this.client.users.createDM(userId)).messages.write(body);
38
- },
39
- };
7
+ async createDM(userId, force = false) {
8
+ if (!force) {
9
+ const dm = await this.client.cache.channels?.get(userId);
10
+ if (dm)
11
+ return dm;
12
+ }
13
+ const data = await this.client.proxy.users('@me').channels.post({
14
+ body: { recipient_id: userId },
15
+ });
16
+ await this.client.cache.channels?.set(userId, '@me', data);
17
+ return new structures_1.DMChannel(this.client, data);
18
+ }
19
+ async deleteDM(userId, reason) {
20
+ const res = await this.client.proxy.channels(userId).delete({ reason });
21
+ await this.client.cache.channels?.removeIfNI(structures_1.BaseChannel.__intent__('@me'), res.id, '@me');
22
+ return new structures_1.DMChannel(this.client, res);
23
+ }
24
+ async fetch(userId, force = false) {
25
+ if (!force) {
26
+ const user = await this.client.cache.users?.get(userId);
27
+ if (user)
28
+ return user;
29
+ }
30
+ const data = await this.client.proxy.users(userId).get();
31
+ await this.client.cache.users?.patch(userId, data);
32
+ return new structures_1.User(this.client, data);
33
+ }
34
+ async write(userId, body) {
35
+ return (await this.client.users.createDM(userId)).messages.write(body);
40
36
  }
41
37
  }
42
38
  exports.UsersShorter = UsersShorter;