dbd.ts
  • Welcome
  • Changelog
  • Guides
    • Adding Events
    • Author-Only Interactions
    • Bot Options
    • Command Handler
    • Context Menus
    • Custom Functions
    • Slash Commands
    • Statuses
    • Variables
  • Callbacks
    • onBotJoin
    • onBotLeave
    • onJoin
    • onLeave
    • onReactionAdd
    • onReactionRemove
    • onReady
    • Space Commands
  • Functions
    • $addActionRow
    • $addButton
    • $addCmdReactions
    • $addField
    • $addSelectMenu
    • $addSelectMenuOption
    • $addThreadMember
    • $addTimestamp
    • $akarui
    • $allMembersCount
    • $approximateMemberCount
    • $approximatePrecenseCount
    • $archiveThread
    • $argCount
    • $attachment
    • $author
    • $authorAvatar
    • $authorID
    • $awaitMessage
    • $ban
    • $banCount
    • $botCount
    • $botLeave
    • $botOwnerID
    • $callFunction
    • $channelCategoryID
    • $channelExists
    • $channelGuildID
    • $channelID
    • $channelName
    • $channelNSFW
    • $channelSendMessage
    • $channelTopic
    • $channelType
    • $checkCondition
    • $clearAllReactions
    • $clearMessages
    • $clearUserMessages
    • $clientID
    • $clientToken
    • $cloneChannel
    • $color
    • $cooldown
    • $cpu
    • $createContextMenuApplication
    • $createFile
    • $createObject
    • $createSlashCommand
    • $createTextChannel
    • $dbPing
    • $defer
    • $delete
    • $deleteChannels
    • $deletecommand
    • $deleteEmojis
    • $deleteMessage
    • $deleteMessageRow
    • $deleteMessageRows
    • $deleteRoles
    • $description
    • $discriminator
    • $divide
    • $djsEval
    • $editMEssage
    • $editMessageRows
    • $endsWith
    • $ephemeral
    • $eval
    • $executionTime
    • $fetchGuildMembers
    • $filter
    • $footer
    • $formatMS
    • $functionCount
    • $get
    • $getChannelSlowmode
    • $getCooldownTime
    • $getServerInvite
    • $getSlashCommandData
    • $getSlashCommandOption
    • $getTimestamp
    • $getUserBadges
    • $guildID
    • $if
    • $ignoreCode
    • $includes
    • $indexOf
    • $isBot
    • $isNumber
    • $kick
    • $let
    • $log
    • $makeReturn
    • $math
    • $packageName
    • $ram
    • $readyTimestamp
    • $replaceText
    • $round
  • Typedefs
    • ApplicationCommandTypes
    • ButtonStyles
    • ComparisonSymbols
    • ImageSizes
    • SlashCommandOptionProperty
    • SlashCommandProperty
Powered by GitBook
On this page
  • Creating Application Command Data
  • Creating a Context Menu
  • Responding to Context Menu Interactions

Was this helpful?

  1. Guides

Context Menus

PreviousCommand HandlerNextCustom Functions

Last updated 3 years ago

Was this helpful?

Context menus are a new, cool way to for users to interact with your bot. Context menus can be accessed by right clicking or tapping on messages/users. They're a great way to surface quick actions for your bot that target messages/users.

Don't forget to add the onInteraction event to your main file. For example:

bot.addEvent([
    "onMessage",
    "onInteraction"
])

Creating Application Command Data

To create a context menu application, you can use the createApplicationCommandData method in bot class:

Template:

bot.createApplicationCommandData({
    type: "type",
    name: "name"
})

There can be 5 guild and 5 global context menu commands per bot.

Example:

bot.createApplicationCommandData({
    type: "USER",
    name: "Punch"
})

Creating a Context Menu

Deploy this context menu to a guild (or globally).

Template:

bot.commands.add({
    name: "deploy",
    type: "basicCommand",
    code: `$if[$botOwnerID!==$authorID;
            You can't use this command!
        ;
            $createContextMenuApplication[guildID/global;contextMenuName]
            Successfully created context menu app!
        ]`
})

Example:

bot.commands.add({
    name: "deploy",
    type: "basicCommand",
    code: `$if[$botOwnerID!==$authorID;
            You can't use this command!
        ;
            $createContextMenuApplication[$guildID;Punch]
            Successfully created context menu app!
        ]`
})

Responding to Context Menu Interactions

To respond to an interaction of a context menu, you can use the contextMenuCommand type.

Template:

bot.commands.add({
    type: "contextMenuCommand",
    name: "name",
    code: `$reply
Hello World`
})

Example:

bot.commands.add({
    type: "contextMenuCommand",
    name: "Punch",
    code: `$reply
        $username wants to punch <@$slashOption[user]>!`
})
View Context Menu Types