Class: RequiredParser
@tagscript/plugin-discord.RequiredParser
The require tag will attempt to convert the given parameter into a channel, user
or role, using name or Id. If the user running the tag is not in the targeted
channel or doesn't have the targeted role or their id isn't same as targeted user's id, the tag will stop processing and
it will send the response if one is given. Multiple role, user or channel
requirements can be given, and should be split by a ,
.
Aliases: allowlist, whitelist
Example
{require(user,role,channel):response}
Example
{require(Moderator)}
{require(#general, #bot-commands):This tag can only be run in #general and #bot-cmds.}
{require(757425366209134764, 668713062186090506, 737961895356792882):You aren't allowed to use this tag.}
Developers need to add the check themselves.
Example
const { Interpreter } = require("tagscript")
const { RequiredParser } = require("@tagscript/plugin-discord")
const ts = new Interpreter(new RequiredParser())
const result = await ts.run("{require(id1, id2):You aren't allowed to use this tag.}")
if (!result.actions.require.ids.includes(interaction.user.id)) {
// add channel, role check here or check using name instead of id
return interaction.reply(result.actions.require.message)
}
Hierarchy
-
BaseParser
↳
RequiredParser
Implements
IParser
Constructors
constructor
• new RequiredParser()
Overrides
BaseParser.constructor
Defined in
tagscript-plugin-discord/src/lib/Parsers/AllowDeny.ts:40
Properties
acceptedNames
• Protected
acceptedNames: string
[]
Inherited from
BaseParser.acceptedNames
Defined in
tagscript/dist/index.d.ts:380
requiredParameter
• Protected
requiredParameter: boolean
Inherited from
BaseParser.requiredParameter
Defined in
tagscript/dist/index.d.ts:381
requiredPayload
• Protected
requiredPayload: boolean
Inherited from
BaseParser.requiredPayload
Defined in
tagscript/dist/index.d.ts:382
Methods
parse
▸ parse(ctx
): null
| ""
Parameters
Name | Type |
---|---|
ctx | Context |
Returns
null
| ""
Implementation of
IParser.parse
Defined in
tagscript-plugin-discord/src/lib/Parsers/AllowDeny.ts:44
willAccept
▸ willAccept(ctx
): boolean
Parameters
Name | Type |
---|---|
ctx | Context |
Returns
boolean
Implementation of
IParser.willAccept
Inherited from
BaseParser.willAccept
Defined in
tagscript/dist/index.d.ts:384