seyfert 1.0.0 → 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.
- package/lib/api/CDN.d.ts +1 -1
- package/lib/api/CDN.js +0 -2
- package/lib/api/Router.js +2 -2
- package/lib/api/Routes/applications.d.ts +29 -33
- package/lib/api/Routes/channels.d.ts +11 -17
- package/lib/api/Routes/interactions.d.ts +3 -7
- package/lib/api/Routes/webhooks.d.ts +4 -6
- package/lib/api/api.d.ts +5 -0
- package/lib/api/api.js +36 -0
- package/lib/api/shared.d.ts +5 -3
- package/lib/builders/Attachment.d.ts +2 -3
- package/lib/builders/Button.d.ts +2 -2
- package/lib/cache/adapters/default.d.ts +1 -0
- package/lib/cache/adapters/default.js +1 -0
- package/lib/cache/adapters/redis.d.ts +1 -0
- package/lib/cache/adapters/redis.js +7 -0
- package/lib/cache/adapters/types.d.ts +1 -0
- package/lib/cache/adapters/workeradapter.d.ts +5 -4
- package/lib/cache/adapters/workeradapter.js +11 -5
- package/lib/cache/index.d.ts +4 -6
- package/lib/cache/index.js +5 -6
- package/lib/cache/resources/default/base.d.ts +2 -1
- package/lib/cache/resources/default/guild-based.d.ts +2 -1
- package/lib/cache/resources/default/guild-based.js +6 -6
- package/lib/cache/resources/default/guild-related.d.ts +2 -1
- package/lib/cache/resources/default/guild-related.js +1 -1
- package/lib/cache/resources/guilds.js +2 -1
- package/lib/cache/resources/overwrites.d.ts +1 -1
- package/lib/cache/resources/overwrites.js +7 -1
- package/lib/client/base.d.ts +18 -171
- package/lib/client/base.js +12 -15
- package/lib/client/client.d.ts +6 -1
- package/lib/client/client.js +13 -12
- package/lib/client/oninteractioncreate.js +4 -4
- package/lib/client/onmessagecreate.js +188 -152
- package/lib/client/workerclient.d.ts +15 -1
- package/lib/client/workerclient.js +135 -27
- package/lib/collection.js +2 -2
- package/lib/commands/applications/chat.d.ts +15 -7
- package/lib/commands/applications/chat.js +7 -7
- package/lib/commands/applications/chatcontext.d.ts +6 -4
- package/lib/commands/applications/chatcontext.js +12 -7
- package/lib/commands/applications/menu.d.ts +5 -1
- package/lib/commands/applications/menu.js +4 -0
- package/lib/commands/applications/menucontext.d.ts +5 -3
- package/lib/commands/applications/menucontext.js +9 -4
- package/lib/commands/applications/options.d.ts +1 -2
- package/lib/commands/decorators.d.ts +17 -5
- package/lib/commands/decorators.js +17 -7
- package/lib/commands/handler.d.ts +5 -5
- package/lib/commands/handler.js +40 -36
- package/lib/commands/optionresolver.d.ts +11 -4
- package/lib/commands/optionresolver.js +6 -4
- package/lib/common/index.d.ts +7 -0
- package/lib/common/index.js +7 -0
- package/lib/common/it/utils.js +2 -0
- package/lib/common/shorters/channels.d.ts +67 -129
- package/lib/common/shorters/channels.js +119 -135
- package/lib/common/shorters/emojis.d.ts +47 -0
- package/lib/common/shorters/emojis.js +80 -0
- package/lib/common/shorters/guilds.d.ts +22 -249
- package/lib/common/shorters/guilds.js +51 -140
- package/lib/common/shorters/members.d.ts +82 -108
- package/lib/common/shorters/members.js +151 -166
- package/lib/common/shorters/messages.d.ts +11 -23
- package/lib/common/shorters/messages.js +58 -104
- package/lib/common/shorters/reactions.d.ts +10 -0
- package/lib/common/shorters/reactions.js +45 -0
- package/lib/common/shorters/roles.d.ts +39 -7
- package/lib/common/shorters/roles.js +74 -42
- package/lib/common/shorters/templates.d.ts +6 -8
- package/lib/common/shorters/templates.js +17 -21
- package/lib/common/shorters/users.d.ts +4 -0
- package/lib/common/shorters/users.js +30 -0
- package/lib/common/shorters/webhook.d.ts +62 -26
- package/lib/common/shorters/webhook.js +113 -58
- package/lib/common/types/options.d.ts +2 -2
- package/lib/common/types/util.d.ts +1 -1
- package/lib/components/handler.d.ts +11 -8
- package/lib/components/handler.js +34 -22
- package/lib/index.d.ts +4 -2
- package/lib/langs/handler.js +7 -2
- package/lib/structures/AutoModerationRule.d.ts +2 -2
- package/lib/structures/ClientUser.d.ts +2 -2
- package/lib/structures/Guild.d.ts +2 -2
- package/lib/structures/GuildEmoji.d.ts +4 -4
- package/lib/structures/GuildEmoji.js +7 -7
- package/lib/structures/GuildMember.d.ts +6 -6
- package/lib/structures/GuildMember.js +2 -2
- package/lib/structures/GuildPreview.d.ts +2 -2
- package/lib/structures/GuildRole.d.ts +2 -2
- package/lib/structures/GuildTemplate.d.ts +2 -2
- package/lib/structures/Interaction.d.ts +7 -8
- package/lib/structures/Interaction.js +1 -1
- package/lib/structures/Message.d.ts +7 -6
- package/lib/structures/Message.js +7 -4
- package/lib/structures/Sticker.d.ts +2 -2
- package/lib/structures/Webhook.d.ts +2 -2
- package/lib/structures/Webhook.js +3 -3
- package/lib/structures/channels.d.ts +19 -20
- package/lib/structures/channels.js +13 -25
- package/lib/structures/extra/Base.d.ts +1 -2
- package/lib/structures/extra/DiscordBase.d.ts +2 -2
- package/lib/websocket/constants/index.js +2 -3
- package/lib/websocket/discord/shard.js +4 -2
- package/lib/websocket/discord/sharder.d.ts +3 -0
- package/lib/websocket/discord/sharder.js +12 -5
- package/lib/websocket/discord/shared.d.ts +3 -0
- package/lib/websocket/discord/worker.d.ts +24 -7
- package/lib/websocket/discord/workermanager.d.ts +30 -6
- package/lib/websocket/discord/workermanager.js +160 -51
- package/package.json +8 -5
|
@@ -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
|
-
*
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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 {
|
|
2
|
-
import { Message,
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
}
|