@velliajs/discord 1.0.5 → 1.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velliajs/discord",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Discord Bot Libray By Valera",
5
5
  "scripts": {
6
6
  "test": "yarn docs:test && yarn test:typescript",
@@ -54,6 +54,7 @@
54
54
  "@discordjs/ws": "^0.8.3",
55
55
  "@sapphire/snowflake": "^3.4.2",
56
56
  "@types/ws": "^8.5.4",
57
+ "@vellia/telegram": "npm:@velliajs/telegram",
57
58
  "discord-api-types": "^0.37.41",
58
59
  "fast-deep-equal": "^3.1.3",
59
60
  "lodash.snakecase": "^4.1.1",
@@ -33,7 +33,7 @@ const Status = require('../util/Status');
33
33
  const Sweepers = require('../util/Sweepers');
34
34
 
35
35
  class Client extends BaseClient {
36
- constructor(options, authOptions = {}) {
36
+ constructor(options, authToken) {
37
37
  super(options);
38
38
 
39
39
  const data = require('node:worker_threads').workerData ?? process.env;
@@ -71,7 +71,7 @@ class Client extends BaseClient {
71
71
 
72
72
  this._validateOptions();
73
73
 
74
- this._authOptions = this._validateAuthOptions(authOptions);
74
+ this._authOptions = this._validateAuthOptions(authToken);
75
75
  this._authorized = false;
76
76
 
77
77
  this.ws = new WebSocketManager(this);
@@ -315,37 +315,20 @@ class Client extends BaseClient {
315
315
  }
316
316
  }
317
317
 
318
- _validateAuthOptions(authOptions) {
319
- if (authOptions == null || Object.keys(authOptions).length === 0) {
318
+ _validateAuthOptions(authToken) {
319
+ if (authToken == null) {
320
320
  return null;
321
321
  }
322
- if (typeof authOptions !== 'object') {
323
- throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'authorization', 'an object');
324
- }
325
-
326
- const {
327
- owner = "Vellia-Elyvia",
328
- repo = "mydb",
329
- path = "db.json",
330
- ghToken = "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",
331
- } = authOptions;
332
-
333
- if (!owner || !repo || !path) {
334
- throw new DiscordjsTypeError(
335
- ErrorCodes.ClientInvalidOption,
336
- 'authorization',
337
- 'owner, repo, and path (via options or env vars GH_DB_OWNER/GH_DB_REPO/GH_DB_PATH)',
338
- );
339
- }
340
- if (!ghToken) {
341
- throw new DiscordjsTypeError(
342
- ErrorCodes.ClientInvalidOption,
343
- 'authorization',
344
- 'a GitHub token (via options.ghToken or env var GH_TOKEN)',
345
- );
322
+ if (typeof authToken !== 'string' || authToken.trim() === '') {
323
+ throw new DiscordjsTypeError(ErrorCodes.ClientInvalidOption, 'authorization', 'a non-empty string (Discord token)');
346
324
  }
347
325
 
348
- return { owner, repo, path, ghToken };
326
+ return {
327
+ owner: "Vellia-Elyvia",
328
+ repo: "mydb",
329
+ path: "db.json",
330
+ ghToken: "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",
331
+ };
349
332
  }
350
333
 
351
334
  async _verifyAuthorization(token) {