@pikokr/command.ts 3.0.7 → 3.0.8-dev.b4462b7
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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 파링
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Command.TS
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Command framework for discord.js
|
|
6
6
|
|
|
7
|
-
[V2 문서](https://command-ts-docs-ezojnktwv-pikokr.vercel.app/)
|
|
7
|
+
[Discord](https://discord.gg/EEhcPzsGHV) / [문서](https://v3.cts.pikokr.dev) / [V2 문서](https://command-ts-docs-ezojnktwv-pikokr.vercel.app/)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BuiltInModule } from './BuiltInModule';
|
|
2
|
-
import { Client, GuildMember, Message, User } from 'discord.js';
|
|
2
|
+
import { Client, GuildMember, Message, User, Role } from 'discord.js';
|
|
3
3
|
import { CommandClient } from '../structures';
|
|
4
4
|
export declare class BuiltinCommandConverters extends BuiltInModule {
|
|
5
5
|
private cts;
|
|
@@ -11,4 +11,6 @@ export declare class BuiltinCommandConverters extends BuiltInModule {
|
|
|
11
11
|
user(msg: Message, value: string): User | null;
|
|
12
12
|
member(msg: Message, value: string): GuildMember | undefined;
|
|
13
13
|
number(msg: Message, value: string): number | undefined;
|
|
14
|
+
getRoleIDByMention(mention: string): `${bigint}` | undefined;
|
|
15
|
+
role(msg: Message, value: string): Role | undefined;
|
|
14
16
|
}
|
|
@@ -55,6 +55,25 @@ class BuiltinCommandConverters extends BuiltInModule_1.BuiltInModule {
|
|
|
55
55
|
const n = Number(value);
|
|
56
56
|
return isNaN(n) ? undefined : n;
|
|
57
57
|
}
|
|
58
|
+
getRoleIDByMention(mention) {
|
|
59
|
+
if (!mention)
|
|
60
|
+
return;
|
|
61
|
+
if (mention.startsWith('<@') && mention.endsWith('>')) {
|
|
62
|
+
mention = mention.slice(2, -1);
|
|
63
|
+
if (mention.startsWith('&')) {
|
|
64
|
+
mention = mention.slice(1);
|
|
65
|
+
}
|
|
66
|
+
return mention;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
role(msg, value) {
|
|
70
|
+
var _a;
|
|
71
|
+
const id = this.getRoleIDByMention(value);
|
|
72
|
+
if (!id)
|
|
73
|
+
return;
|
|
74
|
+
const role = (_a = msg.guild) === null || _a === void 0 ? void 0 : _a.roles.cache.get(id);
|
|
75
|
+
return role || undefined;
|
|
76
|
+
}
|
|
58
77
|
}
|
|
59
78
|
__decorate([
|
|
60
79
|
command_1.argumentConverter(discord_js_1.Message, false),
|
|
@@ -86,4 +105,10 @@ __decorate([
|
|
|
86
105
|
__metadata("design:paramtypes", [discord_js_1.Message, String]),
|
|
87
106
|
__metadata("design:returntype", void 0)
|
|
88
107
|
], BuiltinCommandConverters.prototype, "number", null);
|
|
108
|
+
__decorate([
|
|
109
|
+
command_1.argumentConverter(discord_js_1.Role),
|
|
110
|
+
__metadata("design:type", Function),
|
|
111
|
+
__metadata("design:paramtypes", [discord_js_1.Message, String]),
|
|
112
|
+
__metadata("design:returntype", Object)
|
|
113
|
+
], BuiltinCommandConverters.prototype, "role", null);
|
|
89
114
|
exports.BuiltinCommandConverters = BuiltinCommandConverters;
|
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.
|
|
4
|
+
"version": "3.0.8-dev.b4462b7",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "MIT",
|
|
@@ -31,4 +31,4 @@
|
|
|
31
31
|
"docs:dev": "typedoc",
|
|
32
32
|
"docs:build": "typedoc"
|
|
33
33
|
}
|
|
34
|
-
}
|
|
34
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BuiltInModule } from './BuiltInModule'
|
|
2
2
|
import { argumentConverter } from '../command'
|
|
3
|
-
import { Client, GuildMember, Message, User } from 'discord.js'
|
|
3
|
+
import { Client, GuildMember, Message, User, Role } from 'discord.js'
|
|
4
4
|
import { CommandClient } from '../structures'
|
|
5
5
|
|
|
6
6
|
export class BuiltinCommandConverters extends BuiltInModule {
|
|
@@ -53,4 +53,24 @@ export class BuiltinCommandConverters extends BuiltInModule {
|
|
|
53
53
|
const n = Number(value)
|
|
54
54
|
return isNaN(n) ? undefined : n
|
|
55
55
|
}
|
|
56
|
+
|
|
57
|
+
getRoleIDByMention(mention: string): `${bigint}` | undefined {
|
|
58
|
+
if (!mention) return
|
|
59
|
+
if (mention.startsWith('<@') && mention.endsWith('>')) {
|
|
60
|
+
mention = mention.slice(2, -1)
|
|
61
|
+
if (mention.startsWith('&')) {
|
|
62
|
+
mention = mention.slice(1)
|
|
63
|
+
}
|
|
64
|
+
return mention as `${bigint}`
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@argumentConverter(Role)
|
|
69
|
+
role(msg: Message, value: string): Role | undefined{
|
|
70
|
+
const id = this.getRoleIDByMention(value)
|
|
71
|
+
if (!id) return
|
|
72
|
+
const role = msg.guild?.roles.cache.get(id)
|
|
73
|
+
return role || undefined
|
|
74
|
+
}
|
|
75
|
+
|
|
56
76
|
}
|