Combines multiple filters into a single filter, only allowing the command to be run if all the filters provided allow the command to be run.
Only allow the command to be ran in a specific channel by administrators.
const F = discord.command.filters;
const ADMIN_CHANNEL_ID = '628887548604841984';
const commands = new discord.command.CommandGroup();
commands.raw(
{
name: 'admin',
filters: F.and(F.isChannelId(ADMIN_CHANNEL_ID), F.isAdministrator())
},
(message) => message.reply('hey!')
);
Only allows the command to be run if the user has the discord.Permissions.ADD_REACTIONS permission.
By default, will check for the permission in the current channel that the command is being invoked in. However,
you can specify a specific channelId
as an optional argument, that will override the channel that the permission
will be checked in.
Only allows the command to be run if the user has the discord.Permissions.ATTACH_FILES permission.
By default, will check for the permission in the current channel that the command is being invoked in. However,
you can specify a specific channelId
as an optional argument, that will override the channel that the permission
will be checked in.
Only allows the command to be run if the user has the discord.Permissions.BAN_MEMBERS permission.
Only allows the command to be run if the user has the discord.Permissions.CHANGE_NICKNAME permission.
This differs from discord.command.filters.canManageNicknames in that the discord.Permissions.CHANGE_NICKNAME permission only allows the user to change their own username, and not the username of others. This means that this filter checks if the user can change their own nickname.
Only allows the command to be run if the user has the discord.Permissions.VOICE_CONNECT permission.
By default, will check for the permission in the current channel that the command is being invoked in. However,
you can specify a specific channelId
as an optional argument, that will override the channel that the permission
will be checked in.
Note: Since commands are generally executed in text channels, without a channelId
provided, this checks to see
if the user is able to connect to channels without any specific permission overrides.
Only allows the command to be run if the user has the discord.Permissions.CREATE_INSTANT_INVITE permission.
Only allows the command to be run if the user has the discord.Permissions.VOICE_DEAFEN_MEMBERS permission.
By default, will check for the permission in the current channel that the command is being invoked in. However,
you can specify a specific channelId
as an optional argument, that will override the channel that the permission
will be checked in.
Only allows the command to be run if the user has the discord.Permissions.EMBED_LINKS permission.
By default, will check for the permission in the current channel that the command is being invoked in. However,
you can specify a specific channelId
as an optional argument, that will override the channel that the permission
will be checked in.
Only allows the command to be run if the user has the discord.Permissions.KICK_MEMBERS permission.
Only allows the command to be run if the user has the discord.Permissions.MANAGE_WEBHOOKS permission.
By default, will check for the permission in the current channel that the command is being invoked in. However,
you can specify a specific channelId
as an optional argument, that will override the channel that the permission
will be checked in.
Only allows the command to be run if the user has the discord.Permissions.MANAGE_CHANNELS permission.
By default, will check for the permission in the current channel that the command is being invoked in. However,
you can specify a specific channelId
as an optional argument, that will override the channel that the permission
will be checked in.
Only allows the command to be run if the user has the discord.Permissions.MANAGE_EMOJIS permission.
Only allows the command to be run if the user has the discord.Permissions.MANAGE_GUILD permission.
Only allows the command to be run if the user has the discord.Permissions.MANAGE_WEBHOOKS permission.
This differs from discord.command.filters.canManageChannelWebhooks in that, this permission checks if they can manage all webhooks on the guild, rather than webhooks within a specific channel.
Only allows the command to be run if the user has the discord.Permissions.MANAGE_MESSAGES permission.
By default, will check for the permission in the current channel that the command is being invoked in. However,
you can specify a specific channelId
as an optional argument, that will override the channel that the permission
will be checked in.
Only allows the command to be run if the user has the discord.Permissions.MANAGE_NICKNAMES permission.
Only allows the command to be run if the user has the discord.Permissions.MANAGE_ROLES permission.
Only allows the command to be run if the user has the discord.Permissions.MENTION_EVERYONE permission.
By default, will check for the permission in the current channel that the command is being invoked in. However,
you can specify a specific channelId
as an optional argument, that will override the channel that the permission
will be checked in.
Only allows the command to be run if the user has the discord.Permissions.VOICE_MOVE_MEMBERS permission.
By default, will check for the permission in the current channel that the command is being invoked in. However,
you can specify a specific channelId
as an optional argument, that will override the channel that the permission
will be checked in.
Only allows the command to be run if the user has the discord.Permissions.VOICE_MUTE_MEMBERS permission.
By default, will check for the permission in the current channel that the command is being invoked in. However,
you can specify a specific channelId
as an optional argument, that will override the channel that the permission
will be checked in.
Only allows the command to be run if the user has the discord.Permissions.VOICE_PRIORITY_SPEAKER permission.
By default, will check for the permission in the current channel that the command is being invoked in. However,
you can specify a specific channelId
as an optional argument, that will override the channel that the permission
will be checked in.
Note: Since commands are generally executed in text channels, without a channelId
provided, this checks to see
if the user is able to speak with priority in channels without any specific permission overrides.
Only allows the command to be run if the user has the discord.Permissions.READ_MESSAGE_HISTORY permission.
By default, will check for the permission in the current channel that the command is being invoked in. However,
you can specify a specific channelId
as an optional argument, that will override the channel that the permission
will be checked in.
Only allows the command to be run if the user has the discord.Permissions.READ_MESSAGES permission in a given channel.
Note: This filter always takes a channelId
, as it's implied that the user has the read message permission in the current channel
if they're able to execute a command in that channel. This allows you to check if the user is able to read messages in another
channel.
Only allows the command to be run if the user has the discord.Permissions.SEND_MESSAGES permission in a given channel.
Note: This filter always takes a channelId
, as it's implied that the user has the send message permission in the current channel
if they're able to execute a command in that channel. This allows you to check if the user is able to send messages in another
channel.
Only allows the command to be run if the user has the discord.Permissions.SEND_TTS_MESSAGES permission.
By default, will check for the permission in the current channel that the command is being invoked in. However,
you can specify a specific channelId
as an optional argument, that will override the channel that the permission
will be checked in.
Only allows the command to be run if the user has the discord.Permissions.VOICE_SPEAK permission.
By default, will check for the permission in the current channel that the command is being invoked in. However,
you can specify a specific channelId
as an optional argument, that will override the channel that the permission
will be checked in.
Note: Since commands are generally executed in text channels, without a channelId
provided, this checks to see
if the user is able to speak in channels without any specific permission overrides.
Only allows the command to be run if the user has the discord.Permissions.STREAM permission. Streaming is also known as the "go live" feature inside of Discord.
By default, will check for the permission in the current channel that the command is being invoked in. However,
you can specify a specific channelId
as an optional argument, that will override the channel that the permission
will be checked in.
Only allows the command to be run if the user has the discord.Permissions.EXTERNAL_EMOJIS permission.
By default, will check for the permission in the current channel that the command is being invoked in. However,
you can specify a specific channelId
as an optional argument, that will override the channel that the permission
will be checked in.
Only allows the command to be run if the user has the discord.Permissions.VOICE_USE_VAD permission.
By default, will check for the permission in the current channel that the command is being invoked in. However,
you can specify a specific channelId
as an optional argument, that will override the channel that the permission
will be checked in.
Note: Since commands are generally executed in text channels, without a channelId
provided, this checks to see
if the user is able to speak using voice activity detection in channels without any specific permission overrides.
Only allows the command to be run if the user has the discord.Permissions.VIEW_AUDIT_LOGS permission.
Only allows the command to be run if the user has the discord.Permissions.VIEW_GUILD_ANALYTICS permission.
Only allows the command to be run in the specified channelIds
.
Creates a custom filter, based upon whatever criteria you wish. Additionally, you can provide a custom criteria message.
Checks to see if the user's discriminator is #0001.
const is0001Discriminator = discord.command.filters.custom(
(message) => message.author.discriminator === '0001',
'discriminator must be #0001'
);
Only allows the command to be run if the user has the given permission
in the given channelId
. If the channelId
is not provided, will check to see if they have the given permission in the current channel.
This is a lower level function of the can...
functions located in this module. For example, the following
are equivalent:
discord.command.filters.hasChannelPermission()
discord.command.filters.hasChannelPermission(discord.Permissions.MANAGE_MESSAGES)
Only allows the command to run if the user has all of the specified roles
.
Note: Providing an empty roles
array will cause the script to fail validation.
Only allows the command to be run if the user has the given permission
in the guild.
This is a lower level function of the can...
functions located in this module. For example, the following
are equivalent:
discord.command.filters.canManageGuild()
discord.command.filters.hasGuildPermission(discord.Permissions.MANAGE_GUILD)
Only allows the command to be run if the user has a role that is mentionable by everyone.
Only allows the command to be run if the user has a nickname in the guild.
Only allows the command to be run in a channel which has the specified parentId
.
Only allows the command to run if the user has a given role
.
Note: This is basically equivalent to discord.command.filters.hasSomeRole([role])
. But with a more
specialized error message. Internally, if hasSomeRole
or hasEveryRole
is called with a single
role id, it will use this function instead.
Only allows the command to run if the user has one of the specified roles
.
Note: Providing an empty roles
array will cause the script to fail validation.
Only allow the command to be run if the user has the discord.Permissions.ADMINISTRATOR permission.
Only allows the command to be run in a specified channelId
.
Only allows the command to be run in a channel which is marked nsfw.
Only allow the command to be run by the current guild owner.
Only allows the command to be run by a specified userId
.
Creates a filter that is the inverse of a given filter.
Only allows the command to be ran if the user is NOT an administrator.
const F = discord.command.filters;
const commands = new discord.command.CommandGroup();
commands.raw(
{
name: 'hey',
filters: F.not(F.isAdministrator())
},
(message) => message.reply('hey!')
);
Combines multiple filters into a single filter, only allowing the command to be run if one of the filters provided allow the command to be run.
Only allow the command to be ran in a specific channel, or if the user is an administrator.
const F = discord.command.filters;
const commands = new discord.command.CommandGroup();
commands.raw(
{
name: 'hey',
filters: F.or(F.isChannelId(CHANNEL_ID), F.isAdministrator())
},
(message) => message.reply('hey!')
);
Only allows the command to be run in a channel which has the specified parentIds
.
Suppresses the error message returned by a given filter if the user does not meet its criteria.
This is really useful in combination with the discord.command.filters.isChannelId filter (see below).
Limits a command group to only be usable in a given channel. If the user is not in that channel, and tries to use a command, don't allow it to be used, but also don't tell them which channel they need to be in. For example, if you had an game channel that you wanted to run game commands in:
const F = discord.command.filters;
const GAME_CHANNEL_ID = '628887548604841984';
const gameCommands = new discord.command.CommandGroup({
filters: F.silent(F.isChannelId(GAME_CHANNEL_ID))
});
gameCommands.raw('d6', (message) =>
message.reply(`Your roll is ${(Math.random() * 6) | 0}`)
);
gameCommands.raw('flip', (message) =>
message.reply(`Coin flip is ${Math.random() < 0.5 ? 'heads' : 'tails'}!`)
);
Only allows the command to be run by the specified userIds
.
Wraps a given filter
, making it return a custom criteria message instead of the one provided. This can
add some flavor to your bot by letting you override the built in Pylon filter criteria message.
Wrap the [[discord.command.filter.isAdministrator]] filter, providing a custom criteria message if the user is not an administrator.
const F = discord.command.filters;
// You can now use `coolerAdminFilter` with your commands. You of course don't need to assign this
// to a variable. But if you've gone through the effort of making a cool criteria message, you
// might want to reuse it.
const coolerAdminFilter = F.withCustomMessage(F.isAdministrator, "be an incredibly cool person");
Generated using TypeDoc
Filters allow you to constrain who is able to run a given discord.command.CommandGroup or discord.command.Command.