@z.aourzag/plugzs
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@sapphire/plugin-interactions

Simple plugin for adding Slash Command support in your existing bot.

GitHub codecov npm Depfu

Features

  • Create slash commands with ease
  • Implement slash command support in your existing code base
  • Support for the discord.js library
  • Other things Vlad just doesn't know what/why to list cuz this is literally the basic jist

Installation

You can use the following command to install this package, or replace npm install with your package manager of choice.

npm install @sapphire/plugin-interactions

Usage

First, register the plugin

Note that at this time, we only support discord.js directly! You may use the classes directly if you want to.

import '@sapphire/plugin-interactions/register-discordjs';

Usage with TypeScript

import {
	SlashCommandBuilderFunction,
	SlashCommandBuilder,
	SlashCommandRunFunction,
	SlashCommandInteraction,
	SlashCommandArgs
} from '@sapphire/plugin-interactions';
import { Args, Command } from '@sapphire/framework';
import type { Message } from 'discord.js';

export class UserCommand extends Command {
	public [SlashCommandBuilderFunction]() {
		return new SlashCommandBuilder().setName(this.name).setDescription('Examples are pretty hard, cut me slack!');
	}

	public [SlashCommandRunFunction](interaction: SlashCommandInteraction, args: SlashCommandArgs) {
		return interaction.reply('Hello from slash commands!', { ephemeral: true });
	}

	public run(message: Message, args: Args) {
		return message.reply('Hello from normal commands!');
	}
}

Usage with JavaScript

const { SlashCommandBuilderFunction, SlashCommandBuilder, SlashCommandRunFunction } = require('@sapphire/plugin-interactions');
const { Args, Command } = require('@sapphire/framework');

exports.UserCommand = class extends Command {
	[SlashCommandBuilderFunction]() {
		return new SlashCommandBuilder().setName(this.name).setDescription('Examples are pretty hard, cut me slack!');
	}

	[SlashCommandRunFunction](interaction, args) {
		return interaction.reply('Hello from slash commands!', { ephemeral: true });
	}

	run(message, args) {
		return message.reply('Hello from normal commands!');
	}
};

API Documentation

For the full API documentation please refer to the TypeDoc generated documentation.

Buy us some doughnuts

Sapphire Project is and always will be open source, even if we don't get donations. That being said, we know there are amazing people who may still want to donate just to show their appreciation. Thank you very much in advance!

We accept donations through Ko-fi, PayPal, Patreon and GitHub Sponsorships. You can use the buttons below to donate through your method of choice.

Donate With Address
Ko-fi Click Here
Patreon Click Here
PayPal Click Here

Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

Package Sidebar

Install

npm i @z.aourzag/plugzs

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

94.3 kB

Total Files

61

Last publish

Collaborators

  • zaka