Interaction Kit is a framework for creating Discord slash command bots over the HTTP API
Bot releases are hidden (Show)
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.
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.
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!");
}
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.
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);
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!
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!
Published by IanMitchell over 1 year ago
Fixes some documentation oversights
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!
Published by IanMitchell over 1 year ago
Updates the package to use the new esbuild API
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
Published by IanMitchell over 1 year ago
Fixes documentation errors
Published by IanMitchell over 1 year ago
Adds a missing package description. Thanks to @marinofranz for spotting the issue and fixing it!
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.
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 }));
},
});
Published by IanMitchell over 1 year ago
This update fixes some typos in the documentation and README files
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";
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.
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.
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!
The package now exports a variety of methods and TypeScript integrations. The old default export has become a named export called getDate
.
-const snowflake = require('discord-snowflake');
-let date = snowflake("123456789123456789");
+import { getDate } from "discord-snowflake";
+let date = getDate("123456789123456789");
Snowflake
- A type representing a Discord snowflake.isSnowflake(id: string): boolean
- A typeguard for verifying a value is a Discord snowflake.EPOCH
- The Discord epoch constant.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 SnowflakePublished 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
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.
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)