XenKys / disgroove

A module to interface with Discord

Home Page:https://npmc.dev/disgroove

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

disgroove

A module to interface with Discord

Installation

Node.js v18 or newer required

npm install disgroove

Example

const {
  Client,
  GatewayIntents,
  InteractionType,
  InteractionCallbackType,
  MessageFlags,
} = require("disgroove");
const client = new Client("B0t.T0k3N", {
  intents: GatewayIntents.All,
});

client.once("ready", () => {
  console.log(`${client.user.username} is now online!`);

  client.createGlobalApplicationCommand(client.application.id, {
    name: "ping",
    description: "Responds with Pong! πŸ“",
  });
});

client.on("interactionCreate", async (interaction) => {
  if (interaction.type !== InteractionType.ApplicationCommand) return;

  if (interaction.data.name === "ping") {
    client.createInteractionResponse(interaction.id, interaction.token, {
      type: InteractionCallbackType.ChannelMessageWithSource,
      data: {
        content: "Pong! πŸ“",
        flags: MessageFlags.Ephemeral,
      },
    });
  }
});

client.connect();

More examples on the GitHub repository

About

A module to interface with Discord

https://npmc.dev/disgroove

License:MIT License


Languages

Language:TypeScript 100.0%