@satorijs/adapter-discord 3.0.0 → 3.0.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.
- package/lib/bot.d.ts +2 -3
- package/lib/index.js +4 -17
- package/lib/index.js.map +2 -2
- package/lib/ws.d.ts +3 -8
- package/package.json +2 -2
package/lib/bot.d.ts
CHANGED
|
@@ -2,11 +2,10 @@ import { Bot, Context, Message, Quester, Schema } from '@satorijs/satori';
|
|
|
2
2
|
import { Sender } from './sender';
|
|
3
3
|
import { Internal } from './types';
|
|
4
4
|
import { WsClient } from './ws';
|
|
5
|
-
export declare class DiscordBot extends Bot<
|
|
5
|
+
export declare class DiscordBot<C extends Context = Context> extends Bot<C, DiscordBot.Config> {
|
|
6
6
|
http: Quester;
|
|
7
7
|
internal: Internal;
|
|
8
|
-
constructor(ctx:
|
|
9
|
-
getIntents(): number;
|
|
8
|
+
constructor(ctx: C, config: DiscordBot.Config);
|
|
10
9
|
getSelf(): Promise<import("@satorijs/core").User>;
|
|
11
10
|
private parseQuote;
|
|
12
11
|
sendMessage(channelId: string, content: string, guildId?: string): Promise<string[]>;
|
package/lib/index.js
CHANGED
|
@@ -1349,7 +1349,7 @@ var WsClient = class extends import_satori3.Adapter.WsClient {
|
|
|
1349
1349
|
token: this.bot.config.token,
|
|
1350
1350
|
properties: {},
|
|
1351
1351
|
compress: false,
|
|
1352
|
-
intents: this.bot.
|
|
1352
|
+
intents: this.bot.config.intents
|
|
1353
1353
|
}
|
|
1354
1354
|
}));
|
|
1355
1355
|
}
|
|
@@ -1378,10 +1378,7 @@ __name(WsClient, "WsClient");
|
|
|
1378
1378
|
WsClient2.Config = import_satori3.Schema.intersect([
|
|
1379
1379
|
import_satori3.Schema.object({
|
|
1380
1380
|
gateway: import_satori3.Schema.string().role("url").default("wss://gateway.discord.gg/?v=8&encoding=json").description("要连接的 WebSocket 网关。"),
|
|
1381
|
-
intents: import_satori3.Schema.
|
|
1382
|
-
members: import_satori3.Schema.boolean().description("启用 GUILD_MEMBERS 推送。").default(true),
|
|
1383
|
-
presence: import_satori3.Schema.boolean().description("启用 GUILD_PRESENCES 推送。").default(false)
|
|
1384
|
-
})
|
|
1381
|
+
intents: import_satori3.Schema.bitset(GatewayIntent).description("需要订阅的机器人事件。").default(0 | 512 /* GUILD_MESSAGES */ | 1024 /* GUILD_MESSAGE_REACTIONS */ | 4096 /* DIRECT_MESSAGES */ | 8192 /* DIRECT_MESSAGE_REACTIONS */)
|
|
1385
1382
|
}).description("推送设置"),
|
|
1386
1383
|
import_satori3.Adapter.WsClient.Config
|
|
1387
1384
|
]);
|
|
@@ -1401,16 +1398,6 @@ var DiscordBot = class extends import_satori4.Bot {
|
|
|
1401
1398
|
this.internal = new Internal(this.http);
|
|
1402
1399
|
ctx.plugin(WsClient, this);
|
|
1403
1400
|
}
|
|
1404
|
-
getIntents() {
|
|
1405
|
-
let intents = 0 | 512 /* GUILD_MESSAGES */ | 1024 /* GUILD_MESSAGE_REACTIONS */ | 4096 /* DIRECT_MESSAGES */ | 8192 /* DIRECT_MESSAGE_REACTIONS */;
|
|
1406
|
-
if (this.config.intents.members) {
|
|
1407
|
-
intents |= 2 /* GUILD_MEMBERS */;
|
|
1408
|
-
}
|
|
1409
|
-
if (this.config.intents.presence) {
|
|
1410
|
-
intents |= 256 /* GUILD_PRESENCES */;
|
|
1411
|
-
}
|
|
1412
|
-
return intents;
|
|
1413
|
-
}
|
|
1414
1401
|
async getSelf() {
|
|
1415
1402
|
const data = await this.internal.getCurrentUser();
|
|
1416
1403
|
return adaptUser(data);
|
|
@@ -1429,7 +1416,7 @@ var DiscordBot = class extends import_satori4.Bot {
|
|
|
1429
1416
|
guildId,
|
|
1430
1417
|
subtype: guildId ? "group" : "private"
|
|
1431
1418
|
});
|
|
1432
|
-
if (await this.
|
|
1419
|
+
if (await this.context.serial(session, "before-send", session))
|
|
1433
1420
|
return;
|
|
1434
1421
|
if (!(session == null ? void 0 : session.content))
|
|
1435
1422
|
return [];
|
|
@@ -1442,7 +1429,7 @@ var DiscordBot = class extends import_satori4.Bot {
|
|
|
1442
1429
|
const results = await send(session.content, { message_reference });
|
|
1443
1430
|
for (const id of results) {
|
|
1444
1431
|
session.messageId = id;
|
|
1445
|
-
this.
|
|
1432
|
+
this.context.emit(session, "send", session);
|
|
1446
1433
|
}
|
|
1447
1434
|
return results;
|
|
1448
1435
|
}
|