pandawrapper
TypeScript icon, indicating that this package has built-in type declarations

0.1.0-beta.11a • Public • Published

PandaWrapper

ci

npm version Version NPM Downloads

Version Version Version

Welcome to PandaWrapper, a Discord.JS wrapper in TypeScript.


Examples

Empty Bot

This will create a bot with a prefix of eb?. (ex: eb?ping)

import { WrappedClient } from "pandawrapper";

const client = new WrappedClient("eb?");

// Remember to catch the error that may arise from a failed login.
client.login("token").catch(console.error.bind(console));

Ping MessageCommand

This will create a simple ping message command. (ex: eb?ping)

import { WrappedClient } from "pandawrapper";

const client = new WrappedClient("eb?");

// All commands are builders, so you can chain them on the same line.
const pingMessageCommand = new MessageCommand("ping").setCallback(async message => message.reply("Pong!"));

client.registerMessageCommand(pingMessageCommand);
// Remember to catch the error that may arise from a failed login.
client.login("token").catch(console.error.bind(console));

Managing MessagePermissions of a MessageCommand

This will create and add permissions to the pre-existing ping message command.

import { WrappedClient } from "pandawrapper";

const client = new WrappedClient("eb?");

// All commands are builders, so you can chain them on the same line.
const pingMessageCommand = new MessageCommand("ping").setCallback(async message => message.reply("Pong!"));

// When handling permissions, you can define them all in one go
const pingPermissions: MessagePermissions = {
	allowed: new Set(["memberRoleId"]);
};
pingMessageCommand.setPermissions(pingPermissions);

// or separately.
pingMessageCommand.addDenied("someRoleIdThatCannotUsePing");

client.registerMessageCommand(pingMessageCommand);
// Remember to catch the error that may arise from a failed login.
client.login("token").catch(console.error.bind(console));

Basic SlashCommand Example

This will create a SlashCommand version of the ping command. (ex: /ping)

import { WrappedClient } from "pandawrapper";

const client = new WrappedClient("eb?");

// Remember: All commands are builders, so you can chain them on the same line.
const pingSlashCommand = new SlashCommand("ping", "Pong!")
	.setCallback(async interaction => interaction.reply("Pong!"))
	.setGlobal(false)
	.setGuildId("yourGuildId")
	.addPermission("memberRoleId", "ROLE", true);

client.registerCommandObject(pingSlashCommand);
// Remember to catch the error that may arise from a failed login.
client.login("token").catch(console.error.bind(console));

Readme

Keywords

none

Package Sidebar

Install

npm i pandawrapper

Weekly Downloads

0

Version

0.1.0-beta.11a

License

ISC

Unpacked Size

111 kB

Total Files

56

Last publish

Collaborators

  • tinypandas