command-context 1.0.1
Install from the command line:
Learn more about npm packages
$ npm install @stegripe/command-context@1.0.1
Install via package.json:
"@stegripe/command-context": "1.0.1"
About this version
Plugin for @sapphire/framework used to handle Message & Interaction Command in a single context.
This plugin is used to handle Message & Interaction Command in a single context. It is used to simplify the process of creating commands that can be used in both Message and Interaction contexts.
- Easy to use
- Support for preconditions.
- Based on command class.
@stegripe/command-context depends on the following packages. Be sure to install these along with this package!
You can use the following command to install this package, or replace pnpm install with your package manager of choice.
pnpm install @stegripe/command-contextdeclare module "@sapphire/framework" {
interface CommandOptions {
chatInputCommand?(options: Command.Options): SlashCommandBuilder;
contextMenuCommand?(options: Command.Options): ContextMenuCommandBuilder;
}
}import { Command } from "@sapphire/framework";
import { CommandContext, ContextCommand } from "@stegripe/command-context";
import { ApplicationCommandType, ContextMenuCommandBuilder, SlashCommandBuilder } from "discord.js";
export class MyCommand extends ContextCommand {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, {
...options,
name: "my-command",
description: "This is my command.",
chatInputCommand() {
return new SlashCommandBuilder()
.setName(this.name)
.setDescription(this.description);
},
contextMenuCommand() {
return new ContextMenuCommandBuilder()
.setName(this.name)
.setType(ApplicationCommandType.Message);
}
});
}
public async contextRun(ctx: CommandContext): Promise<void> {
if (ctx.isCommandInteraction() && !ctx.deferred) await ctx.deferReply();
await ctx.reply("Hello, World!");
}
}import { ApplyOptions } from "@sapphire/decorators";
import { Command } from "@sapphire/framework";
import { CommandContext, ContextCommand } from "@stegripe/command-context";
import { SlashCommandBuilder } from "discord.js";
@ApplyOptions<Command.Options>({
name: "my-command",
description: "This is my command.",
chatInputCommand(opts) {
return new SlashCommandBuilder().setName(opts.name).setDescription(opts.description);
},
contextMenuCommand(opts) {
return new ContextMenuCommandBuilder()
.setName(opts.name)
.setType(ApplicationCommandType.Message);
}
})
export class MyCommand extends ContextCommand {
public async contextRun(ctx: CommandContext): Promise<void> {
if (ctx.isCommandInteraction() && !ctx.deferred) await ctx.deferReply();
await ctx.reply("Hello, World!");
}
}Details
- command-context
-
stegripe
- over 1 year ago
- AGPL-3.0
- 8 dependencies
Assets
- command-context-1.0.1.tgz
Download activity
- Total downloads 0
- Last 30 days 0
- Last week 0
- Today 0