filters

filters

type: { allowUsers: (userIds: Snowflake[]) => CommandFilter; and: (items: CommandFilter[]) => CommandFilter; custom: (check: CommandFilter[“check”]) => CommandFilter; guildOnly: (message: string) => CommandFilter; hasAllRoles: (roleIds: Snowflake[]) => CommandFilter; hasAnyRole: (roleIds: Snowflake[]) => CommandFilter; hasRole: (roleId: Snowflake) => CommandFilter; not: (item: CommandFilter) => CommandFilter; or: (items: CommandFilter[]) => CommandFilter; silent: (item: CommandFilter) => CommandFilter; withMessage: (item: CommandFilter, message: string) => CommandFilter; }

Ready-made command filters. Pass them in a command’s filters array; they run in order and the first failure stops the command.

filters: [discord.filters.or(discord.filters.hasRole(modRoleId), discord.filters.allowUsers(ownerId))],

Values

Name

Value

Description

allowUsers

object

Allows only these user IDs.

and

object

Passes when every filter passes; replies with the first failure.

custom

object

Wraps a check function as a filter.

guildOnly

object

Rejects use outside a server, replying with message or a default.

hasAllRoles

object

Requires the member to have every one of these roles.

hasAnyRole

object

Requires the member to have at least one of these roles.

hasRole

object

Requires the member to have this role.

not

object

Inverts a filter. A failure caused by not is silent.

or

object

Passes when any filter passes; replies with the last failure.

silent

object

Stops the command without replying when the filter fails.

withMessage

object

Replaces a filter’s failure reply with message .