nexushub-commands 2.2.0 → 2.2.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.
@@ -8,12 +8,13 @@ const migrated_1 = require("evogram/lib/migrated");
8
8
  const Client_1 = require("../../Client");
9
9
  let RegistrationCommand = RegistrationCommand_1 = class RegistrationCommand extends migrated_1.Command {
10
10
  isExecutable(context) {
11
- var _a;
11
+ var _a, _b, _c, _d;
12
12
  if (context.state.fromMirror)
13
13
  return false;
14
14
  if (!((_a = context.state.mammoth) === null || _a === void 0 ? void 0 : _a.mirror))
15
15
  return true;
16
- if (/\/start(\s)?(\d+)?/.test(context.text) && context.mirror.isMain)
16
+ const [, , refCode] = /(\/(start|registration)(\s)?(\d+))?/.exec(context.text) || [];
17
+ if (((_b = context.state.mirror) === null || _b === void 0 ? void 0 : _b.isMain) && refCode && Number((_d = (_c = context.user.userDB) === null || _c === void 0 ? void 0 : _c.payload) === null || _d === void 0 ? void 0 : _d.refCode) !== Number(refCode))
17
18
  return true;
18
19
  return false;
19
20
  }
@@ -21,8 +22,8 @@ let RegistrationCommand = RegistrationCommand_1 = class RegistrationCommand exte
21
22
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
22
23
  var _a;
23
24
  const config = Client_1.Client.config(context);
24
- if (/\/start \d+/.test(context.text) || Number(context.text))
25
- context.user.userDB.payload.refCode = Number((_a = /(\/start )?(\d+)/.exec(context.text)) === null || _a === void 0 ? void 0 : _a[2]);
25
+ if (/\/(start|registration) \d+/.test(context.text) || Number(context.text))
26
+ context.user.userDB.payload.refCode = Number((_a = /(\/(start|registration) )?(\d+)/.exec(context.text)) === null || _a === void 0 ? void 0 : _a[2]);
26
27
  if (!context.user.userDB.payload.agreement)
27
28
  return context.sendFormatted({
28
29
  body: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexushub-commands",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "main": "./lib/index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -6,9 +6,10 @@ import { Client, DepositConfig } from '../../Client'
6
6
  export class RegistrationCommand extends Command {
7
7
  public isExecutable(context: CommandContext): boolean {
8
8
  if (context.state.fromMirror) return false
9
-
10
9
  if (!context.state.mammoth?.mirror) return true
11
- if (/\/start(\s)?(\d+)?/.test(context.text!) && context.mirror.isMain) return true
10
+
11
+ const [, , refCode] = /(\/(start|registration)(\s)?(\d+))?/.exec(context.text!) || []
12
+ if (context.state.mirror?.isMain && refCode && Number(context.user.userDB?.payload?.refCode) !== Number(refCode)) return true
12
13
 
13
14
  return false
14
15
  }
@@ -16,7 +17,7 @@ export class RegistrationCommand extends Command {
16
17
  public async execute(context: CommandContext) {
17
18
  const config = Client.config(context)
18
19
 
19
- if (/\/start \d+/.test(context.text!) || Number(context.text)) context.user.userDB.payload.refCode = Number(/(\/start )?(\d+)/.exec(context.text!)?.[2])
20
+ if (/\/(start|registration) \d+/.test(context.text!) || Number(context.text)) context.user.userDB.payload.refCode = Number(/(\/(start|registration) )?(\d+)/.exec(context.text!)?.[2])
20
21
  if (!context.user.userDB.payload.agreement)
21
22
  return context.sendFormatted(
22
23
  {