Results

Namespace

Type

Filters allow you to constrain who is able to run a given discord.command.CommandGroup or discord.command.Command.

Index

Type aliases

CommandFilterCriteria

CommandFilterCriteria: string | object

Functions

and

  • and(...filters: ICommandFilter[]): ICommandFilter
  • 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.

    Example:

    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!')
    );

    Parameters

    Returns ICommandFilter

canAddReactions

  • canAddReactions(channelId?: Snowflake): ICommandFilter
  • 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.

    Parameters

    Returns ICommandFilter

canAttachFiles

  • canAttachFiles(channelId?: Snowflake): ICommandFilter
  • 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.

    Parameters

    Returns ICommandFilter

canBanMembers

canChangeNickname

canConnect

  • canConnect(channelId?: Snowflake): ICommandFilter
  • 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.

    Parameters

    Returns ICommandFilter

canCreateInstantInvite

canDeafenMembers

  • canDeafenMembers(channelId?: Snowflake): ICommandFilter
  • 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.

    Parameters

    Returns ICommandFilter

canEmbedLinks

  • canEmbedLinks(channelId?: Snowflake): ICommandFilter
  • 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.

    Parameters

    Returns ICommandFilter

canKickMembers

canManageChannelWebhooks

  • canManageChannelWebhooks(channelId?: Snowflake): ICommandFilter
  • 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.

    Parameters

    Returns ICommandFilter

canManageChannels

  • canManageChannels(channelId?: Snowflake): ICommandFilter
  • 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.

    Parameters

    Returns ICommandFilter

canManageEmojis

canManageGuild

canManageGuildWebhooks

canManageMessages

  • canManageMessages(channelId?: Snowflake): ICommandFilter
  • 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.

    Parameters

    Returns ICommandFilter

canManageNicknames

canManageRoles

canMentionEveryone

  • canMentionEveryone(channelId?: Snowflake): ICommandFilter
  • 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.

    Parameters

    Returns ICommandFilter

canMoveMembers

  • canMoveMembers(channelId?: Snowflake): ICommandFilter
  • 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.

    Parameters

    Returns ICommandFilter

canMuteMembers

  • canMuteMembers(channelId?: Snowflake): ICommandFilter
  • 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.

    Parameters

    Returns ICommandFilter

canPrioritySpeaker

  • canPrioritySpeaker(channelId?: Snowflake): ICommandFilter
  • 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.

    Parameters

    Returns ICommandFilter

canReadMessageHistory

  • canReadMessageHistory(channelId?: Snowflake): ICommandFilter
  • 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.

    Parameters

    Returns ICommandFilter

canReadMessages

  • canReadMessages(channelId: Snowflake): ICommandFilter
  • 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.

    Parameters

    Returns ICommandFilter

canSendMessages

  • canSendMessages(channelId: Snowflake): ICommandFilter
  • 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.

    Parameters

    Returns ICommandFilter

canSendTtsMessages

  • canSendTtsMessages(channelId?: Snowflake): ICommandFilter
  • 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.

    Parameters

    Returns ICommandFilter

canSpeak

  • canSpeak(channelId?: Snowflake): ICommandFilter
  • 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.

    Parameters

    Returns ICommandFilter

canStream

  • canStream(channelId?: Snowflake): ICommandFilter
  • 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.

    Parameters

    Returns ICommandFilter

canUseExternalEmojis

  • canUseExternalEmojis(channelId?: Snowflake): ICommandFilter
  • 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.

    Parameters

    Returns ICommandFilter

canUseVoiceActivity

  • canUseVoiceActivity(channelId?: Snowflake): ICommandFilter
  • 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.

    Parameters

    Returns ICommandFilter

canViewAuditLog

canViewGuildInsights

channelIdIn

custom

  • custom(filter: function, filterCriteria?: string | function): ICommandFilter
  • Creates a custom filter, based upon whatever criteria you wish. Additionally, you can provide a custom criteria message.

    Example:

    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'
    );

    Parameters

    • filter: function
    • Optional filterCriteria: string | function

    Returns ICommandFilter

hasChannelPermission

  • hasChannelPermission(permission: Permissions, channelId?: Snowflake): ICommandFilter
  • 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)

    Parameters

    Returns ICommandFilter

hasEveryRole

hasGuildPermission

  • hasGuildPermission(permission: Permissions): ICommandFilter
  • 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)

    Parameters

    Returns ICommandFilter

hasMentionableRole

  • hasMentionableRole(): ICommandFilter
  • Only allows the command to be run if the user has a role that is mentionable by everyone.

    Returns ICommandFilter

hasNickname

hasParentId

hasRole

  • hasRole(role: Snowflake): ICommandFilter
  • 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.

    Parameters

    Returns ICommandFilter

hasSomeRole

isAdministrator

isChannelId

isChannelNsfw

isOwner

isUserId

not

  • not(filter: ICommandFilter): ICommandFilter
  • Creates a filter that is the inverse of a given filter.

    Example:

    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!')
    );

    Parameters

    Returns ICommandFilter

or

  • or(...filters: ICommandFilter[]): ICommandFilter
  • 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.

    Example:

    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!')
    );

    Parameters

    Returns ICommandFilter

parentIdIn

silent

  • silent(filter: ICommandFilter): ICommandFilter
  • 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).

    Example:

    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'}!`)
    );

    Parameters

    Returns ICommandFilter

userIdIn

withCustomMessage

  • withCustomMessage(filter: ICommandFilter, filterCriteria: string | function): ICommandFilter
  • 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.

    Example:

    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");

    Parameters

    Returns ICommandFilter

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc