Skip to main content

Context Menu Commands

Context Menu commands appear as an option in the right-click or long-press menu of Users and Messages. In Purplet, they are structured very closely to Slash Commands, but without the options parameter.

User Commands

User commands target Users or Server Members, which are resolved to a User class.

src/features/user-command.ts
import { $userCommand } from 'purplet';

export default $userContextCommand({
name: 'Get User Info',
handle(user) {
this.showMessage(`Selected user is ${user.tag}`);
}
});

Message Commands

Message commands target Messages inside of Text Channels, which are resolved to a Message class.

src/features/message-command.ts
import { $userCommand } from 'purplet';

export default $messageContextCommand({
name: 'Get Author Info',
handle(message) {
this.showMessage(`Selected message was sent by ${message.author.tag}`);
}
});

Permissions

Context Menu Commands have the same permission system as Slash Commands.

Deploying Commands

Commands are not automatically deployed in production, please read Building for Production.