Skip to main content

Function: RegisterMessageContextMenuCommand()

RegisterMessageContextMenuCommand<CMD>(optionsFn: (builder: ContextMenuCommandBuilder, command: ThisType<CMD> & CMD) => ContextMenuCommandBuilder, registryOptions?: RegisterOptions): ClassDecorator

Defined in: piece-decorators.ts:253

Decorator for registering message context menu command.

Type Parameters

Type ParameterDefault type
CMD extends Command<Args, CommandOptions>Command<Args, CommandOptions>

Parameters

ParameterTypeDescription
optionsFn(builder: ContextMenuCommandBuilder, command: ThisType<CMD> & CMD) => ContextMenuCommandBuilderThe function that returns options to pass to the registry.
registryOptions?RegisterOptions-

Returns

ClassDecorator

Examples

import { RegisterMessageContextMenuCommand } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';
import { ApplicationIntegrationType, InteractionContextType, type MessageContextMenuCommandInteraction } from 'discord.js';

(at)RegisterMessageContextMenuCommand((builder, command) => builder
.setName(command.name)
.setContexts(InteractionContextType.Guild)
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall)
)
export class UserCommand extends Command {
public override contextMenuRun(interaction: MessageContextMenuCommandInteraction) {
return interaction.reply({ content: 'HI!' })
}
}
import { RegisterMessageContextMenuCommand } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';
import { ApplicationIntegrationType, InteractionContextType, type MessageContextMenuCommandInteraction } from 'discord.js';

(at)RegisterMessageContextMenuCommand((builder, command) => builder
.setName(command.name)
.setContexts(InteractionContextType.Guild)
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall),
{
idHints: ['737141877803057244'],
guildIds: ['737141877803057244']
}
)
export class UserCommand extends Command {
public override contextMenuRun(interaction: MessageContextMenuCommandInteraction) {
return interaction.reply({ content: 'HI!' })
}
}
import { RegisterMessageContextMenuCommand } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';
import { ApplicationIntegrationType, InteractionContextType, type MessageContextMenuCommandInteraction } from 'discord.js';

(at)RegisterMessageContextMenuCommand((builder, command) => builder
.setName(command.name)
.setContexts(InteractionContextType.Guild)
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall)
)
export class UserCommand extends Command {
public override contextMenuRun(interaction: MessageContextMenuCommandInteraction) {
return interaction.reply({ content: 'HI!' })
}
}
import { RegisterMessageContextMenuCommand } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';
import { ApplicationIntegrationType, InteractionContextType, type MessageContextMenuCommandInteraction } from 'discord.js';

(at)RegisterMessageContextMenuCommand((builder) => builder
.setName('Send HI')
.setContexts(InteractionContextType.Guild)
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall)
)
export class UserCommand extends Command {
public override contextMenuRun(interaction: MessageContextMenuCommandInteraction) {
return interaction.reply({ content: 'HI!' })
}
}
import { ApplyOptions, RegisterMessageContextMenuCommand } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';
import { ApplicationIntegrationType, InteractionContextType, type MessageContextMenuCommandInteraction } from 'discord.js';

(at)ApplyOptions<Command.Options>({
enabled: true
})
(at)RegisterMessageContextMenuCommand((builder, command) => builder
.setName(command.name)
.setContexts(InteractionContextType.Guild)
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall)
)
export class UserCommand extends Command {
public override contextMenuRun(interaction: MessageContextMenuCommandInteraction) {
return interaction.reply({ content: 'HI!' })
}
}