@mallusrgreat/djs-context
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

DJS Context

This package helps you create a combination of a chat input command interaction and a message. You can use properties available to both of them.

const { Context } = require("@mallusrgreat/djs-context");
// or
import { Context } from "@mallusrgreat/djs-context";

client.on("messageCreate", (msg) => {
  if (!msg.content.toLowerCase().startsWith("!ping")) return;
  const context = new Context(msg);
  handlePingCommand(context);
});
client.on("interactionCreate", (interaction) => {
  if (!interaction.isChatInputCommand() || interaction.commandName !== "ping")
    return;
  const context = new Context(interaction);
  handlePingCommand(context);
});
async function handlePingCommand(context) {
  const replied = await context.reply("Pinging...");
  // This line of code makes use of the "ms" npm package.
  const time = ms(replied.createdTimestamp - context.createdTimestamp);
  await context.editReply(`Pong! ${time}`);
}

Readme

Keywords

none

Package Sidebar

Install

npm i @mallusrgreat/djs-context

Weekly Downloads

1

Version

1.0.7

License

MIT

Unpacked Size

17.4 kB

Total Files

8

Last publish

Collaborators

  • mallusrgreat