interaction-kit

Interaction Kit is a framework for creating Discord slash command bots over the HTTP API

Downloads
13.6K
Stars
117
Committers
22

Bot releases are hidden (Show)

interaction-kit - discord-bitflag v1.0.1 Latest Release

Published by IanMitchell 11 months ago

Fixes a typing issue with the flags. They now should autcomplete correctly while using them. Special thanks to @Darker-Ink for finding and fixing this issue, and for @ckohen for improving the typing.

interaction-kit - discord-bit flag v1.0.0

Published by IanMitchell about 1 year ago

A JavaScript wrapper for Discord bitflags. You can easily modify Permissions, Intents, User flags, Channel Flags, and more with this library.

Usage

import { PermissionFlags, PermissionsBitField } from "discord-bitflag";

const response = await fetch(DISCORD_API, { ...options });
const permissions = new PermissionsBitField(response.permissions);

if (permissions.has(PermissionFlags.BanMembers)) {
	console.log("This user can ban members!");
}

if (permissions.has(PermissionsBitField.ALL)) {
	console.log("This user has all permissions!");
}

if (permissions.hasWithoutAdmin(PermissionsBitField.ALL)) {
	console.log("This user REALLY has all permissions!");
}
interaction-kit - bitflag-js v1.0.0

Published by IanMitchell about 1 year ago

This package provides a class for working with bitflag fields. These structures are very useful as a way to condense a list of boolean values into a single number. They are perfect matches for things like user flags, permissions, and more.

bitflag-js is written in TypeScript and uses bigints instead of numbers.

Usage

import { BitField } from "bitflags-js";

const UserBadges = {
	VERIFIED: 1n << 0n,
	CONTRIBUTOR: 1n << 1n,
	SUPPORTER: 1n << 2n,
	VIP: 1n << 3n,
};

const bitfield = new BitField();
bitfield.add(UserBadges.VERIFIED);
bitfield.add(UserBadges.CONTRIBUTOR);

if (bitfield.has(UserBadges.VERIFIED)) {
	console.log("This user is verified!");
}

console.log(bitfield.value);
interaction-kit - discord-verify v1.2.0

Published by IanMitchell over 1 year ago

Adds an AWS export to enable discord-verify usage on Lambda. Within your function, you can use it like this:

import { isValid } from "discord-verify/aws";

const handler = (event: APIGatewayProxyEvent) => {
  const isValid = await isValid(event);

  if (!isValid) {
    return {
      statusCode: 401,
      body: 'Invalid request signature',
    };
  }

  // ...
} 

Special thanks to @suneettipirneni for writing the PR!

interaction-kit - discord-verify v1.1.0

Published by IanMitchell over 1 year ago

This adds replay attack protection. By default, any request received 15 minutes after the timestamp header is rejected. You can customize this behavior by setting an optional parameter.

Special thanks to @jaw0r3k and @botatooo for contributing to this release!

interaction-kit - discord-request v1.0.1

Published by IanMitchell over 1 year ago

Fixes some documentation oversights

interaction-kit - discord-request v1.0.0

Published by IanMitchell over 1 year ago

The first stable version of discord-request. This package is a thin wrapper around the discord-api, but does not handle rate limits or other errors automatically for you. It does handle formatting requests and uploads. For more information on this project, check the package README!

interaction-kit - discord-edge-runner v1.0.2

Published by IanMitchell over 1 year ago

Updates the package to use the new esbuild API

interaction-kit - discord-error v3.0.1

Published by IanMitchell over 1 year ago

Fixes a bug encountered when parsing Discord error groups. The error string should now correctly identify array positions

interaction-kit - discord-verify v1.0.3

Published by IanMitchell over 1 year ago

Fixes documentation errors

interaction-kit - discord-edge-runner v1.0.1

Published by IanMitchell over 1 year ago

Adds a missing package description. Thanks to @marinofranz for spotting the issue and fixing it!

interaction-kit - discord-edge-runner v1.0.0

Published by IanMitchell over 1 year ago

This is the initial release for discord-edge-runner. This package compiles and runs a Discord HTTP interactions bot from an Edge VM. It is intended for use when locally developing JavaScript or TypeScript HTTP bots.

This package will automatically watch your bot's source files for changes and live reload when one is detected.

Usage

npm i -D discord-edge-runner

In your development script you can then use the package like this:

import server from "discord-edge-runner";

const runner = await server({
	entrypoint: "./bot.ts",
	port: 3000,
	env: {
		APPLICATION_ID: process.env.APPLICATION_ID,
		PUBLIC_KEY: process.env.PUBLIC_KEY,
		TOKEN: process.env.TOKEN,
		// Handle the output from the "debug" npm package.
		DEBUG: process.env.DEBUG ?? "",
		DEBUG_COLORS: "ON",
		// Chalk
		FORCE_COLOR: "1",
	},
	onReload: async () => {
		// When the bot reloads, update its commands on Discord
		await updateCommands(guildId);
	},
	onError: (error: unknown) => {
		log(chalk.red({ error }));
	},
});
interaction-kit - discord-verify 1.0.2

Published by IanMitchell over 1 year ago

This update fixes some typos in the documentation and README files

interaction-kit - discord-error v3.0.0

Published by IanMitchell over 1 year ago

Version 3 exports named values instead default exports. This will allow us to add more detailed errors based on Discord API error codes.

- import DiscordError from "discord-error";
+ import { DiscordError } from "discord-error";
interaction-kit - discord-error v2.0.0

Published by IanMitchell almost 2 years ago

Publishing version 2 because I had previously published version 1 while messing around with lerna locally -- oops. This package is now ready for library and application usage.

interaction-kit - discord-verify v1.0.0

Published by IanMitchell about 2 years ago

The first full version of discord-verify is out! It supports Vercel, Cloudflare, and Node.js out of the box. It is significantly more performant than discord-interactions.

To find out more information, check out the project README.

interaction-kit - discord-snowflake v2.0.0

Published by IanMitchell about 2 years ago

discord-snowflake v2.0.0 adds several functions for interacting with Discord snowflakes. Special thanks to theking465 for the original package implementation!

Breaking Changes

The package now exports a variety of methods and TypeScript integrations. The old default export has become a named export called getDate.

Migrating

-const snowflake = require('discord-snowflake');
-let date = snowflake("123456789123456789");
+import { getDate } from "discord-snowflake";
+let date = getDate("123456789123456789");

New Features

TypeScript Types and Typeguards

  • Snowflake - A type representing a Discord snowflake.
  • isSnowflake(id: string): boolean - A typeguard for verifying a value is a Discord snowflake.

Constants

  • EPOCH - The Discord epoch constant.

Methods

  • getTimestamp(snowflake: Snowflake): number - Returns the parsed unix timestamp.
  • getDate(snowflake: Snowflake): Date - Returns the parsed date the timestamp represents.
  • getWorkerId(snowflake: Snowflake): number - Returns the parsed worker ID.
  • getProcessId(snowflake: Snowflake): Number - Returns the parsed process ID.
  • getIncrement(snowflake: Snowflake): number - Returns the parsed increment.
  • parse(snowflake: Snowflake) - Returns an object containing all the parsed parts of a Snowflake
interaction-kit - Create Project and Dev CLI

Published by IanMitchell almost 3 years ago

Just published a new beta that sketches out the new project and development flow. A lot of features aren't implemented / aren't completely yet, but you should be able to get a new project off the ground by running

npx create-ikit-app

After you have a new project, run

npm run dev

And code away! If you have any feedback on the flow, bug reports, or opinions about the API design please post them on the GitHub Discussion or in our Discord Server

interaction-kit - Component Registration and Type Fixes

Published by IanMitchell over 3 years ago

Fixes several type problems and allows components to be registered. This prevents Message Component Interactions from being dropped until after a slash command has been executed upon boot.

interaction-kit - Smart Command Updates

Published by IanMitchell over 3 years ago

When you boot a development server, Interaction Kit will now calculate a delta between the server command and local one, and only submit a command update if there is a difference. This should help avoid rate limits while people are doing dev work (especially when using Nodemon)