-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathargCount.ts
More file actions
32 lines (30 loc) · 825 Bytes
/
argCount.ts
File metadata and controls
32 lines (30 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
* SPDX-License-Identifier: LGPL-3.0-or-later
* Copyright © 2026 BotForge
*/
import { ArgType, NativeFunction, Return } from "../../structures"
export default new NativeFunction({
name: "$argCount",
version: "1.0.0",
description: "Counts the number of args in a message",
aliases: ["$argsCount"],
unwrap: true,
brackets: false,
output: ArgType.Number,
args: [
{
name: "text",
description: "Text to count arguments",
required: true,
rest: false,
type: ArgType.String,
},
],
execute(ctx, [text]) {
if (this.hasFields) {
const trimmed = text.trim()
return this.success(trimmed ? trimmed.split(/ +/).length : 0)
}
return this.success(ctx.args.length)
},
})