@satorijs/adapter-discord 4.5.11 → 4.6.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/bot.d.ts +4 -4
- package/lib/index.cjs +22 -12
- package/package.json +3 -3
- package/src/bot.ts +10 -10
- package/src/utils.ts +12 -2
package/lib/bot.d.ts
CHANGED
|
@@ -40,10 +40,10 @@ export declare class DiscordBot<C extends Context = Context> extends Bot<C, Disc
|
|
|
40
40
|
getChannelList(guildId: string): Promise<{
|
|
41
41
|
data: Universal.Channel[];
|
|
42
42
|
}>;
|
|
43
|
-
createReaction(channelId: string, messageId: string,
|
|
44
|
-
deleteReaction(channelId: string, messageId: string,
|
|
45
|
-
clearReaction(channelId: string, messageId: string,
|
|
46
|
-
getReactionList(channelId: string, messageId: string,
|
|
43
|
+
createReaction(channelId: string, messageId: string, emojiId: string): Promise<void>;
|
|
44
|
+
deleteReaction(channelId: string, messageId: string, emojiId: string, userId?: string): Promise<void>;
|
|
45
|
+
clearReaction(channelId: string, messageId: string, emojiId?: string): Promise<void>;
|
|
46
|
+
getReactionList(channelId: string, messageId: string, emojiId: string, after?: string): Promise<{
|
|
47
47
|
data: Universal.User[];
|
|
48
48
|
next: string;
|
|
49
49
|
}>;
|
package/lib/index.cjs
CHANGED
|
@@ -1230,7 +1230,7 @@ var decodeUser = /* @__PURE__ */ __name((user) => ({
|
|
|
1230
1230
|
var decodeGuildMember = /* @__PURE__ */ __name((member) => ({
|
|
1231
1231
|
user: member.user && decodeUser(member.user),
|
|
1232
1232
|
nick: member.nick,
|
|
1233
|
-
roles: member.roles,
|
|
1233
|
+
roles: member.roles?.map((id) => ({ id })),
|
|
1234
1234
|
joinedAt: member.joined_at ? new Date(member.joined_at).valueOf() : void 0
|
|
1235
1235
|
}), "decodeGuildMember");
|
|
1236
1236
|
var decodeGuild = /* @__PURE__ */ __name((data) => ({
|
|
@@ -1492,11 +1492,21 @@ async function adaptSession(bot, input) {
|
|
|
1492
1492
|
session.event.button = {
|
|
1493
1493
|
id
|
|
1494
1494
|
};
|
|
1495
|
+
} else if (input.t === "CHANNEL_CREATE") {
|
|
1496
|
+
session.type = "channel-added";
|
|
1497
|
+
session.guildId = input.d.guild_id;
|
|
1498
|
+
session.channelId = input.d.id;
|
|
1499
|
+
session.event.channel = decodeChannel(input.d);
|
|
1495
1500
|
} else if (input.t === "CHANNEL_UPDATE") {
|
|
1496
1501
|
session.type = "channel-updated";
|
|
1497
1502
|
session.guildId = input.d.guild_id;
|
|
1498
|
-
session.subtype = input.d.guild_id ? "group" : "private";
|
|
1499
1503
|
session.channelId = input.d.id;
|
|
1504
|
+
session.event.channel = decodeChannel(input.d);
|
|
1505
|
+
} else if (input.t === "CHANNEL_DELETE") {
|
|
1506
|
+
session.type = "channel-removed";
|
|
1507
|
+
session.guildId = input.d.guild_id;
|
|
1508
|
+
session.channelId = input.d.id;
|
|
1509
|
+
session.event.channel = decodeChannel(input.d);
|
|
1500
1510
|
} else {
|
|
1501
1511
|
return;
|
|
1502
1512
|
}
|
|
@@ -2244,25 +2254,25 @@ var DiscordBot = class extends import_core5.Bot {
|
|
|
2244
2254
|
const channels = await this.internal.getGuildChannels(guildId);
|
|
2245
2255
|
return { data: channels.map(decodeChannel) };
|
|
2246
2256
|
}
|
|
2247
|
-
createReaction(channelId, messageId,
|
|
2248
|
-
return this.internal.createReaction(channelId, messageId,
|
|
2257
|
+
createReaction(channelId, messageId, emojiId) {
|
|
2258
|
+
return this.internal.createReaction(channelId, messageId, emojiId);
|
|
2249
2259
|
}
|
|
2250
|
-
deleteReaction(channelId, messageId,
|
|
2260
|
+
deleteReaction(channelId, messageId, emojiId, userId) {
|
|
2251
2261
|
if (!userId) {
|
|
2252
|
-
return this.internal.deleteOwnReaction(channelId, messageId,
|
|
2262
|
+
return this.internal.deleteOwnReaction(channelId, messageId, emojiId);
|
|
2253
2263
|
} else {
|
|
2254
|
-
return this.internal.deleteUserReaction(channelId, messageId,
|
|
2264
|
+
return this.internal.deleteUserReaction(channelId, messageId, emojiId, userId);
|
|
2255
2265
|
}
|
|
2256
2266
|
}
|
|
2257
|
-
clearReaction(channelId, messageId,
|
|
2258
|
-
if (!
|
|
2267
|
+
clearReaction(channelId, messageId, emojiId) {
|
|
2268
|
+
if (!emojiId) {
|
|
2259
2269
|
return this.internal.deleteAllReactions(channelId, messageId);
|
|
2260
2270
|
} else {
|
|
2261
|
-
return this.internal.deleteAllReactionsForEmoji(channelId, messageId,
|
|
2271
|
+
return this.internal.deleteAllReactionsForEmoji(channelId, messageId, emojiId);
|
|
2262
2272
|
}
|
|
2263
2273
|
}
|
|
2264
|
-
async getReactionList(channelId, messageId,
|
|
2265
|
-
const data = await this.internal.getReactions(channelId, messageId,
|
|
2274
|
+
async getReactionList(channelId, messageId, emojiId, after) {
|
|
2275
|
+
const data = await this.internal.getReactions(channelId, messageId, emojiId, { after, limit: 100 });
|
|
2266
2276
|
return { data: data.map(decodeUser), next: data[99]?.id };
|
|
2267
2277
|
}
|
|
2268
2278
|
setGuildMemberRole(guildId, userId, roleId) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@satorijs/adapter-discord",
|
|
3
3
|
"description": "Discord Adapter for Satorijs",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.6.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.cjs",
|
|
7
7
|
"typings": "lib/index.d.ts",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"chat"
|
|
34
34
|
],
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@satorijs/core": "^4.
|
|
36
|
+
"@satorijs/core": "^4.6.0",
|
|
37
37
|
"cordis": "^3.18.1"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@satorijs/core": "^4.
|
|
40
|
+
"@satorijs/core": "^4.6.0"
|
|
41
41
|
}
|
|
42
42
|
}
|
package/src/bot.ts
CHANGED
|
@@ -155,28 +155,28 @@ export class DiscordBot<C extends Context = Context> extends Bot<C, DiscordBot.C
|
|
|
155
155
|
return { data: channels.map(Discord.decodeChannel) }
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
createReaction(channelId: string, messageId: string,
|
|
159
|
-
return this.internal.createReaction(channelId, messageId,
|
|
158
|
+
createReaction(channelId: string, messageId: string, emojiId: string) {
|
|
159
|
+
return this.internal.createReaction(channelId, messageId, emojiId)
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
deleteReaction(channelId: string, messageId: string,
|
|
162
|
+
deleteReaction(channelId: string, messageId: string, emojiId: string, userId?: string) {
|
|
163
163
|
if (!userId) {
|
|
164
|
-
return this.internal.deleteOwnReaction(channelId, messageId,
|
|
164
|
+
return this.internal.deleteOwnReaction(channelId, messageId, emojiId)
|
|
165
165
|
} else {
|
|
166
|
-
return this.internal.deleteUserReaction(channelId, messageId,
|
|
166
|
+
return this.internal.deleteUserReaction(channelId, messageId, emojiId, userId)
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
clearReaction(channelId: string, messageId: string,
|
|
171
|
-
if (!
|
|
170
|
+
clearReaction(channelId: string, messageId: string, emojiId?: string) {
|
|
171
|
+
if (!emojiId) {
|
|
172
172
|
return this.internal.deleteAllReactions(channelId, messageId)
|
|
173
173
|
} else {
|
|
174
|
-
return this.internal.deleteAllReactionsForEmoji(channelId, messageId,
|
|
174
|
+
return this.internal.deleteAllReactionsForEmoji(channelId, messageId, emojiId)
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
async getReactionList(channelId: string, messageId: string,
|
|
179
|
-
const data = await this.internal.getReactions(channelId, messageId,
|
|
178
|
+
async getReactionList(channelId: string, messageId: string, emojiId: string, after?: string) {
|
|
179
|
+
const data = await this.internal.getReactions(channelId, messageId, emojiId, { after, limit: 100 })
|
|
180
180
|
return { data: data.map(Discord.decodeUser), next: data[99]?.id }
|
|
181
181
|
}
|
|
182
182
|
|
package/src/utils.ts
CHANGED
|
@@ -28,7 +28,7 @@ export const decodeUser = (user: Discord.User): Universal.User => ({
|
|
|
28
28
|
export const decodeGuildMember = (member: Partial<Discord.GuildMember>): Universal.GuildMember => ({
|
|
29
29
|
user: member.user && decodeUser(member.user),
|
|
30
30
|
nick: member.nick,
|
|
31
|
-
roles: member.roles,
|
|
31
|
+
roles: member.roles?.map(id => ({ id })),
|
|
32
32
|
joinedAt: member.joined_at ? new Date(member.joined_at).valueOf() : undefined,
|
|
33
33
|
})
|
|
34
34
|
|
|
@@ -334,11 +334,21 @@ export async function adaptSession<C extends Context>(bot: DiscordBot<C>, input:
|
|
|
334
334
|
session.event.button = {
|
|
335
335
|
id,
|
|
336
336
|
}
|
|
337
|
+
} else if (input.t === 'CHANNEL_CREATE') {
|
|
338
|
+
session.type = 'channel-added'
|
|
339
|
+
session.guildId = input.d.guild_id
|
|
340
|
+
session.channelId = input.d.id
|
|
341
|
+
session.event.channel = decodeChannel(input.d)
|
|
337
342
|
} else if (input.t === 'CHANNEL_UPDATE') {
|
|
338
343
|
session.type = 'channel-updated'
|
|
339
344
|
session.guildId = input.d.guild_id
|
|
340
|
-
session.subtype = input.d.guild_id ? 'group' : 'private'
|
|
341
345
|
session.channelId = input.d.id
|
|
346
|
+
session.event.channel = decodeChannel(input.d)
|
|
347
|
+
} else if (input.t === 'CHANNEL_DELETE') {
|
|
348
|
+
session.type = 'channel-removed'
|
|
349
|
+
session.guildId = input.d.guild_id
|
|
350
|
+
session.channelId = input.d.id
|
|
351
|
+
session.event.channel = decodeChannel(input.d)
|
|
342
352
|
} else {
|
|
343
353
|
return
|
|
344
354
|
}
|