@pikokr/command.ts 3.0.8-dev.0b83b2b → 3.0.8-dev.69ff8c2
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/.all-contributorsrc +33 -0
- package/README.md +4 -4
- package/dist/builtinModules/BuiltinCommandConverters.js +15 -3
- package/dist/builtinModules/CommandHandler.js +3 -0
- package/dist/structures/CommandClient.d.ts +2 -1
- package/dist/structures/CommandClient.js +1 -0
- package/package.json +1 -1
- package/src/builtinModules/BuiltinCommandConverters.ts +10 -2
- package/src/builtinModules/CommandHandler.ts +4 -0
- package/src/structures/CommandClient.ts +3 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files": [
|
|
3
|
+
"README.md"
|
|
4
|
+
],
|
|
5
|
+
"imageSize": 100,
|
|
6
|
+
"contributorsPerLine": 7,
|
|
7
|
+
"contributorsSortAlphabetically": false,
|
|
8
|
+
"badgeTemplate": "[](#contributors)",
|
|
9
|
+
"contributorTemplate": "<a href=\"<%= contributor.profile %>\"><img src=\"<%= contributor.avatar_url %>\" width=\"<%= options.imageSize %>px;\" alt=\"\"/><br /><sub><b><%= contributor.name %></b></sub></a>",
|
|
10
|
+
"types": {
|
|
11
|
+
"custom": {
|
|
12
|
+
"symbol": "🔭",
|
|
13
|
+
"description": "A custom contribution type.",
|
|
14
|
+
"link": "[<%= symbol %>](<%= url %> \"<%= description %>\"),"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"skipCi": true,
|
|
18
|
+
"contributors": [
|
|
19
|
+
{
|
|
20
|
+
"login": "pikokr",
|
|
21
|
+
"name": "파링",
|
|
22
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/68010770?v=4",
|
|
23
|
+
"profile": "https://pikokr.dev",
|
|
24
|
+
"contributions": [
|
|
25
|
+
"code"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"projectName": "command.ts",
|
|
30
|
+
"projectOwner": "pikokr",
|
|
31
|
+
"repoType": "github",
|
|
32
|
+
"repoHost": "https://github.com"
|
|
33
|
+
}
|
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Command.TS
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/pikokr/command.ts/actions/workflows/publish.yml)
|
|
4
4
|
|
|
5
|
-
[
|
|
5
|
+

|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Command framework for discord.js
|
|
8
8
|
|
|
9
|
-
[V2 문서](https://command-ts-docs-ezojnktwv-pikokr.vercel.app/)
|
|
9
|
+
[Discord](https://discord.gg/EEhcPzsGHV) / [문서](https://v3.cts.pikokr.dev) / [V2 문서](https://command-ts-docs-ezojnktwv-pikokr.vercel.app/)
|
|
@@ -37,18 +37,30 @@ class BuiltinCommandConverters extends BuiltInModule_1.BuiltInModule {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
user(msg, value) {
|
|
40
|
+
let user = this.client.users.cache.get(value);
|
|
41
|
+
if (user)
|
|
42
|
+
return user;
|
|
43
|
+
user = this.client.users.cache.find(x => x.tag === value);
|
|
44
|
+
if (user)
|
|
45
|
+
return user;
|
|
40
46
|
const id = this.getUserIDByMention(value);
|
|
41
47
|
if (!id)
|
|
42
48
|
return null;
|
|
43
|
-
|
|
49
|
+
user = this.client.users.cache.get(id);
|
|
44
50
|
return user || null;
|
|
45
51
|
}
|
|
46
52
|
member(msg, value) {
|
|
47
|
-
var _a;
|
|
53
|
+
var _a, _b, _c;
|
|
54
|
+
let user = (_a = msg.guild) === null || _a === void 0 ? void 0 : _a.members.cache.get(value);
|
|
55
|
+
if (!user)
|
|
56
|
+
return user;
|
|
57
|
+
user = (_b = msg.guild) === null || _b === void 0 ? void 0 : _b.members.cache.find(x => x.user.tag === value);
|
|
58
|
+
if (user)
|
|
59
|
+
return user;
|
|
48
60
|
const id = this.getUserIDByMention(value);
|
|
49
61
|
if (!id)
|
|
50
62
|
return;
|
|
51
|
-
|
|
63
|
+
user = (_c = msg.guild) === null || _c === void 0 ? void 0 : _c.members.cache.get(id);
|
|
52
64
|
return user || undefined;
|
|
53
65
|
}
|
|
54
66
|
number(msg, value) {
|
|
@@ -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[];
|
package/package.json
CHANGED
|
@@ -34,17 +34,25 @@ export class BuiltinCommandConverters extends BuiltInModule {
|
|
|
34
34
|
|
|
35
35
|
@argumentConverter(User)
|
|
36
36
|
user(msg: Message, value: string): User | null {
|
|
37
|
+
let user = this.client.users.cache.get(value)
|
|
38
|
+
if (user) return user
|
|
39
|
+
user = this.client.users.cache.find(x=>x.tag === value)
|
|
40
|
+
if (user) return user
|
|
37
41
|
const id = this.getUserIDByMention(value)
|
|
38
42
|
if (!id) return null
|
|
39
|
-
|
|
43
|
+
user = this.client.users.cache.get(id)
|
|
40
44
|
return user || null
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
@argumentConverter(GuildMember)
|
|
44
48
|
member(msg: Message, value: string): GuildMember | undefined {
|
|
49
|
+
let user = msg.guild?.members.cache.get(value)
|
|
50
|
+
if (!user) return user
|
|
51
|
+
user = msg.guild?.members.cache.find(x=>x.user.tag===value)
|
|
52
|
+
if (user) return user
|
|
45
53
|
const id = this.getUserIDByMention(value)
|
|
46
54
|
if (!id) return
|
|
47
|
-
|
|
55
|
+
user = msg.guild?.members.cache.get(id)
|
|
48
56
|
return user || undefined
|
|
49
57
|
}
|
|
50
58
|
|
|
@@ -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 {
|
|
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: {
|