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,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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
7
|
-
return
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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,6 +2,10 @@ 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
|
+
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>;
|
|
5
9
|
get users(): {
|
|
6
10
|
createDM: (userId: string, force?: boolean) => Promise<DMChannel>;
|
|
7
11
|
deleteDM: (userId: string, reason?: string) => Promise<DMChannel>;
|
|
@@ -4,6 +4,36 @@ 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
|
+
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);
|
|
36
|
+
}
|
|
7
37
|
get users() {
|
|
8
38
|
return {
|
|
9
39
|
createDM: async (userId, force = false) => {
|
|
@@ -1,31 +1,67 @@
|
|
|
1
|
-
import type { RESTPatchAPIWebhookJSONBody, RESTPatchAPIWebhookWithTokenJSONBody,
|
|
2
|
-
import { type MessageWebhookMethodEditParams, type MessageWebhookMethodWriteParams
|
|
1
|
+
import type { RESTPatchAPIWebhookJSONBody, RESTPatchAPIWebhookWithTokenJSONBody, RESTPostAPIChannelWebhookJSONBody } from '..';
|
|
2
|
+
import { Webhook, WebhookMessage, type MessageWebhookMethodEditParams, type MessageWebhookMethodWriteParams } from '../../structures';
|
|
3
3
|
import { BaseShorter } from './base';
|
|
4
4
|
export declare class WebhookShorter extends BaseShorter {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
5
|
+
create(channelId: string, body: RESTPostAPIChannelWebhookJSONBody): Promise<Webhook>;
|
|
6
|
+
/**
|
|
7
|
+
* Deletes a webhook.
|
|
8
|
+
* @param webhookId The ID of the webhook.
|
|
9
|
+
* @param options The optional parameters including token and reason.
|
|
10
|
+
* @returns A Promise that resolves when the webhook is deleted.
|
|
11
|
+
*/
|
|
12
|
+
delete(webhookId: string, options: WebhookShorterOptionalParams): Promise<never>;
|
|
13
|
+
/**
|
|
14
|
+
* Edits a webhook.
|
|
15
|
+
* @param webhookId The ID of the webhook.
|
|
16
|
+
* @param body The data to update the webhook with.
|
|
17
|
+
* @param options The optional parameters including token and reason.
|
|
18
|
+
* @returns A Promise that resolves when the webhook is edited.
|
|
19
|
+
*/
|
|
20
|
+
edit(webhookId: string, body: RESTPatchAPIWebhookWithTokenJSONBody | RESTPatchAPIWebhookJSONBody, options: WebhookShorterOptionalParams): Promise<import("discord-api-types/rest/v10/webhook").RESTGetAPIWebhookWithTokenResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Fetches a webhook.
|
|
23
|
+
* @param webhookId The ID of the webhook.
|
|
24
|
+
* @param token The token of the webhook (optional).
|
|
25
|
+
* @returns A Promise that resolves to the fetched webhook.
|
|
26
|
+
*/
|
|
27
|
+
fetch(webhookId: string, token?: string): Promise<Webhook>;
|
|
28
|
+
/**
|
|
29
|
+
* Writes a message using the webhook.
|
|
30
|
+
* @param webhookId The ID of the webhook.
|
|
31
|
+
* @param token The token of the webhook.
|
|
32
|
+
* @param data The data for writing the message.
|
|
33
|
+
* @returns A Promise that resolves to the written message.
|
|
34
|
+
*/
|
|
35
|
+
writeMessage(webhookId: string, token: string, { body: data, ...payload }: MessageWebhookMethodWriteParams): Promise<WebhookMessage | null>;
|
|
36
|
+
/**
|
|
37
|
+
* Edits a message sent by the webhook.
|
|
38
|
+
* @param webhookId The ID of the webhook.
|
|
39
|
+
* @param token The token of the webhook.
|
|
40
|
+
* @param messageId The ID of the message to edit.
|
|
41
|
+
* @param data The data for editing the message.
|
|
42
|
+
* @returns A Promise that resolves to the edited message.
|
|
43
|
+
*/
|
|
44
|
+
editMessage(webhookId: string, token: string, { messageId, body: data, ...json }: MessageWebhookMethodEditParams): Promise<WebhookMessage>;
|
|
45
|
+
/**
|
|
46
|
+
* Deletes a message sent by the webhook.
|
|
47
|
+
* @param webhookId The ID of the webhook.
|
|
48
|
+
* @param token The token of the webhook.
|
|
49
|
+
* @param messageId The ID of the message to delete.
|
|
50
|
+
* @param reason The reason for deleting the message.
|
|
51
|
+
* @returns A Promise that resolves when the message is deleted.
|
|
52
|
+
*/
|
|
53
|
+
deleteMessage(webhookId: string, token: string, messageId: string, reason?: string): Promise<never>;
|
|
54
|
+
/**
|
|
55
|
+
* Fetches a message sent by the webhook.
|
|
56
|
+
* @param webhookId The ID of the webhook.
|
|
57
|
+
* @param token The token of the webhook.
|
|
58
|
+
* @param messageId The ID of the message to fetch.
|
|
59
|
+
* @param threadId The ID of the thread the message belongs to.
|
|
60
|
+
* @returns A Promise that resolves to the fetched message, or undefined if not found.
|
|
61
|
+
*/
|
|
62
|
+
fetchMessage(webhookId: string, token: string, messageId: string, threadId?: string): Promise<WebhookMessage | undefined>;
|
|
63
|
+
listFromGuild(guildId: string): Promise<Webhook[]>;
|
|
64
|
+
listFromChannel(channelId: string): Promise<Webhook[]>;
|
|
29
65
|
}
|
|
30
66
|
export type WebhookShorterOptionalParams = Partial<{
|
|
31
67
|
token: string;
|