qaut.js 1.0.0 → 1.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/README.md +6 -0
- package/package.json +1 -1
- package/src/index.d.ts +4 -1
- package/src/index.js +18 -0
package/README.md
CHANGED
|
@@ -53,6 +53,12 @@ client.on(Events.MessageCreate, async message => {
|
|
|
53
53
|
client.login();
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
+
`Client` keeps the Node.js process alive after login by default. For one-shot scripts, pass:
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
const client = new Client({ token: process.env.QAUT_TOKEN, keepAlive: false });
|
|
60
|
+
```
|
|
61
|
+
|
|
56
62
|
## Builders
|
|
57
63
|
|
|
58
64
|
- `EmbedBuilder`
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -111,8 +111,11 @@ export declare class Client extends EventEmitter {
|
|
|
111
111
|
rest: REST;
|
|
112
112
|
user: unknown;
|
|
113
113
|
intents: IntentBitField;
|
|
114
|
-
|
|
114
|
+
keepAlive: boolean;
|
|
115
|
+
constructor(options?: { token?: string; intents?: Array<number | bigint | string> | number | bigint | string; restBaseUrl?: string; keepAlive?: boolean });
|
|
115
116
|
login(token?: string): Promise<string>;
|
|
117
|
+
startKeepAlive(): this;
|
|
118
|
+
destroy(): this;
|
|
116
119
|
setPresence(presence?: Record<string, unknown>): Promise<unknown>;
|
|
117
120
|
setStatus(status: string): Promise<unknown>;
|
|
118
121
|
channel(id: string): TextChannel;
|
package/src/index.js
CHANGED
|
@@ -243,6 +243,8 @@ class Client extends EventEmitter {
|
|
|
243
243
|
this.intents = new IntentBitField(options.intents || 0);
|
|
244
244
|
this.rest = new REST({ token: this.token, baseUrl: options.restBaseUrl || DefaultRestBase });
|
|
245
245
|
this.user = null;
|
|
246
|
+
this.keepAlive = options.keepAlive !== false;
|
|
247
|
+
this.keepAliveInterval = null;
|
|
246
248
|
}
|
|
247
249
|
|
|
248
250
|
async login(token = this.token) {
|
|
@@ -251,10 +253,26 @@ class Client extends EventEmitter {
|
|
|
251
253
|
this.rest.setToken(token);
|
|
252
254
|
const me = await this.rest.get('/bot/me');
|
|
253
255
|
this.user = me;
|
|
256
|
+
if (this.keepAlive) this.startKeepAlive();
|
|
254
257
|
this.emit(Events.ClientReady, me);
|
|
255
258
|
return token;
|
|
256
259
|
}
|
|
257
260
|
|
|
261
|
+
startKeepAlive() {
|
|
262
|
+
if (this.keepAliveInterval) return this;
|
|
263
|
+
this.keepAliveInterval = setInterval(() => {
|
|
264
|
+
this.emit(Events.Debug, 'QauT.js keep-alive heartbeat');
|
|
265
|
+
}, 30_000);
|
|
266
|
+
return this;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
destroy() {
|
|
270
|
+
if (this.keepAliveInterval) clearInterval(this.keepAliveInterval);
|
|
271
|
+
this.keepAliveInterval = null;
|
|
272
|
+
this.user = null;
|
|
273
|
+
return this;
|
|
274
|
+
}
|
|
275
|
+
|
|
258
276
|
async setPresence(presence = {}) {
|
|
259
277
|
return this.rest.patch('/bot/presence', presence);
|
|
260
278
|
}
|