@pikokr/command.ts 3.0.8-dev.b4462b7 → 3.0.8-dev.f90db26

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.
@@ -32,6 +32,9 @@ class CommandHandler extends BuiltInModule_1.BuiltInModule {
32
32
  }
33
33
  message(msg) {
34
34
  return __awaiter(this, void 0, void 0, function* () {
35
+ if (!(yield this.client.options.command.check(msg))) {
36
+ return;
37
+ }
35
38
  const error = (error) => this.client.client.emit('commandError', error, msg);
36
39
  try {
37
40
  const prefixList = typeof this.client.options.command.prefix === 'string'
@@ -1,9 +1,10 @@
1
1
  import { Registry } from './Registry';
2
- import { Client, Snowflake } from 'discord.js';
2
+ import { Client, Message, Snowflake } from 'discord.js';
3
3
  import { CoolDownAdapter } from '../command';
4
4
  import { REST } from '@discordjs/rest';
5
5
  export interface CommandOptions {
6
6
  prefix: string | ((msg: any) => string | Promise<string | string[]> | string[]) | string[];
7
+ check: (msg: Message) => boolean | Promise<boolean>;
7
8
  }
8
9
  export interface SlashCommandOptions {
9
10
  guild?: Snowflake | Snowflake[];
@@ -44,6 +44,7 @@ class CommandClient {
44
44
  this.options = lodash_1.default.merge({
45
45
  command: {
46
46
  prefix: '!',
47
+ check: () => true
47
48
  },
48
49
  owners: 'auto',
49
50
  slashCommands: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pikokr/command.ts",
3
3
  "description": "Discord.js command framework for typescript.",
4
- "version": "3.0.8-dev.b4462b7",
4
+ "version": "3.0.8-dev.f90db26",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "MIT",
@@ -17,6 +17,10 @@ export class CommandHandler extends BuiltInModule {
17
17
 
18
18
  @listener('messageCreate')
19
19
  async message(msg: Message) {
20
+ if (!await this.client.options.command.check(msg)) {
21
+ return
22
+ }
23
+
20
24
  const error = (error: Error) => this.client.client.emit('commandError', error, msg)
21
25
 
22
26
  try {
@@ -1,12 +1,13 @@
1
1
  import _ from 'lodash'
2
2
  import { Registry } from './Registry'
3
- import { Client, Snowflake, User } from 'discord.js'
3
+ import {Client, Message, Snowflake, User} from 'discord.js'
4
4
  import { BuiltinCommandConverters, BuiltinSlashCommandConverters, CommandHandler } from '../builtinModules'
5
5
  import { CoolDownAdapter, DefaultCoolDownAdapter } from '../command'
6
6
  import { REST } from '@discordjs/rest'
7
7
 
8
8
  export interface CommandOptions {
9
9
  prefix: string | ((msg: any) => string | Promise<string | string[]> | string[]) | string[]
10
+ check: (msg: Message) => boolean|Promise<boolean>
10
11
  }
11
12
 
12
13
  export interface SlashCommandOptions {
@@ -64,6 +65,7 @@ export class CommandClient {
64
65
  {
65
66
  command: {
66
67
  prefix: '!',
68
+ check: () => true
67
69
  },
68
70
  owners: 'auto',
69
71
  slashCommands: {