-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathjsonHas.ts
More file actions
36 lines (34 loc) · 958 Bytes
/
jsonHas.ts
File metadata and controls
36 lines (34 loc) · 958 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
33
34
35
36
/*
* SPDX-License-Identifier: LGPL-3.0-or-later
* Copyright © 2026 BotForge
*/
import { ArgType, NativeFunction } from "../../structures/@internal/NativeFunction"
export default new NativeFunction({
name: "$jsonHas",
version: "2.2.0",
description: "Returns whether a key exists in a JSON object",
brackets: true,
unwrap: true,
args: [
{
name: "variable",
description: "The variable that holds json",
required: true,
type: ArgType.String,
rest: false
},
{
name: "key",
description: "The key to check for",
type: ArgType.String,
required: true,
rest: false
}
],
output: ArgType.Boolean,
execute(ctx, [ name, key ]) {
const json = ctx.getEnvironmentKey(name)
if (!json) return this.success()
return this.success(Object.hasOwn(json, key))
}
})