Giter VIP home page Giter VIP logo

interaction-kit's Introduction

Interaction Kit

Our end strategy is being acquired by iCrawl

๐Ÿšง INTERACTION KIT IS UNDER CONSTRUCTION AND IS NOT READY FOR USE ๐Ÿ—

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

HTTP vs Gateway

TL;DR: you probably should be using discord.js unless you know why you're here.

There are two ways for bots to recieve events from Discord. Most API wrappers such as discord.js use a WebSocket connection called a "Gateway" to receive events, but Interaction Kit receives Interaction events over HTTP. As such, there are some major points to keep in mind before deciding to use Interaction Kit.

Gateway

The Gateway is a WebSocket that a bot maintains with Discord whenever it is online, giving it events as they happen. The bot is able to subscribe to a wide array of events through Gateway Intents, allowing it to be notified on events such as message sends, a member changing their nickname or a guild changing its icon.

This is the only way to receive the majority of events Discord provides, and when dealing with users or guilds you can generally be sure you are operating on current information with sufficient caching.

The main drawback of the Gateway is that it requires your bot to maintain a connection with Discord at all times. While there are affordable hosts for smaller scale bots, scaling can become expensive quickly and some developers have very low budgets.

HTTP

HTTP-only bots are sent Interaction events through HTTP requests sent from Discord. These generally have a higher latency than a WebSocket connection from the same host and cannot listen for other types of event.

As a result of this, HTTP-only bots lack real time updates to members and guilds, so unless a bot utilizes REST API requests to get the latest data the chance that any cached data will be stale is significant.

On the other hand, they are much more scalable than Gateway-based bots, with a variety of "serverless" or "edge" plans on the market allowing HTTP-only bots to scale more easily and affordably than Gateway bots, with generous free plans that allow smaller bots to get off the ground without major infrastructure costs.

It needs to be emphasized that this approach does not work for all cases, as most real-time data can only be accessed through the Gateway - before making the decision to make a bot HTTP-only, care needs to be taken to ensure that Gateway features are not required.

TODO: Write

interaction-kit's People

Contributors

alii avatar benricheson101 avatar ckohen avatar commanderroot avatar commandtechno avatar darker-ink avatar github-actions[bot] avatar hex2f avatar ianmitchell avatar j-human avatar jaw0r3k avatar joseywoermann avatar marinofranz avatar mrhappyma avatar rodentman87 avatar shocktr avatar ssmmiles avatar stalruth avatar suneettipirneni avatar tristancamejo avatar vladfrangu avatar zeldafan0225 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

interaction-kit's Issues

Prettify and standardize logging

Lot of ugly console.log statements out there. Not sure if debug is the right choice to use, but should grab a lib and make the log statements generally better

[TS] "Ian your embed constructor is bad"

Real title should probably be "Embed constructor doesn't allow omitting the options parameter"

Describe the bug

When creating a new button, you have to manually set the options to null, otherwise TS will give you an error.
image

To Reproduce

import { Command, Embed } from "interaction-kit";

export default new Command({
    name: "embed",
    description: "Sends an embed",
    handler: (interaction) => {
        interaction.reply({
            embed: new Embed().setTitle("test"), // Error occurs here
        });
    },
});

Additional context

  • interaction-kit V 0.1.1
  • TypeScript

Solution (by @ThaTiemsz):

-    constructor(options: EmbedDefinition | null) {
+    constructor(options?: EmbedDefinition) {

in https://github.com/IanMitchell/interaction-kit/blob/main/packages/interaction-kit/src/components/embed.ts#L27

Add Lifecycle Hooks

Need to figure out names and which are needed, but something like "beforeInteraction" and "afterInteraction"

Add `interaction-kit new` Command

This command should take in optional arguments and prompt for the rest, and then scaffold a new app. The options should look like this:

  • --server - Development Server ID
  • --token - Bot Token
  • --public_key - Bot Public Key
  • --application_id - Bot Application ID

Any options not passed in should be prompted during the process (if someone passes in an empty string, we should allow it and clearly explain where to get the value and where to add it later).

The file structure should look like this:

application/
โ”œโ”€ node_modules/
โ”œโ”€ src/
โ”‚  โ”œโ”€ commands/
โ”‚  โ”‚  โ”œโ”€ ping.js
โ”‚  โ”œโ”€ index.js
โ”œโ”€ .gitignore
โ”œโ”€ .env
โ”œโ”€ package.json
โ”œโ”€ README.md

Add support for Context Menus

Describe the request
Context Menus were introduced a few days ago, and I think interaction-kit should support them.

Example Usage
N/A

Additional context
N/A

Serverless Functions Clear Component Map

Right now if a bot sends a message with a button, then the instance dies, and a user clicks a button, Interaction Kit doesn't know what to do with it. Right now we lazily instantiate that list, as users run commands. We need a way to instead load this list on boot, for the most part.

Add Command Inputs

We have a rough Class / API setup for them, but they aren't currently integrated at all. They need to be added to the serialization methods and tested

Add Livereload to `interaction-kit dev`

Delaying this functionality a bit to speed up alpha 1. We'll want to auto-update the command handlers when a file is saved, and also take a look at the command signature - if it's changed, we should fire an update event.

Remove 'guide' files

Oops, trout.js and deschtimes.js weren't supposed to make it into the repository.

Describe the difference between gateway and HTTP bots

Add a small section in the readme explaining the differences between the gateway and HTTP api, and compare the advantages / disadvantages of both to help people who are new to this topic / don't know why something isn't working as they thought it would be.

Fix dev command

We need to move it into a process we can kill instead of using a cached import that never refreshes

Add Prisma Example

I love Prisma, you love Prisma, we all love Prisma. Let's show the world how Interaction Kit loves Prisma.

Dependency Audit

After things settle down a bit, I want to audit the dependencies and see if anything can be removed or updated - I know we get a lot of deprecated warnings on install right now

Add Validations

There are a bunch of TODO comments for adding validations to our library - we can ship some alphas and betas before adding it, but we should have these in before v1

Error on startup without module specifier resolution set to "node"

Describe the bug
When attempting to start up, an error is thrown immediately if the --es-module-specifier-resolution flag is configured incorrectly.

To Reproduce
1.) Start an app using interaction-kit without the --es-module-specifier-resolution flag set to node in the run command.
2.) Observe the "cannot find module '.../node_modules/interaction-kit/dist/data/snowflake'" error.

Rethink `starter-commands`

I like the idea of having several ready-to-go commands available, but I'm not sure I love having a README embedded in them like that. Renaming it to starter-kit with a README and a commands directory feels less clear, though (although it does give flexibility to do more with it). That said, we also have the examples directory for more complex things. Not sure what I want to do with this yet - anyone have thoughts?

Add publish GitHub Action

Would be nice to have a GitHub action handle the package publish flow. Need to look into how that works with TypeScript too

Add Vercel Example

I really like how Next.js has a tons of examples right in the repo that you can deploy and test - I think this is a pattern that would be useful here (to a more limited extent).

Serverless slash commands have seen a lot of community interest, so having an example on how to build and deploy one would be really useful.

Figure out Testing

This is two-parter, and probably more of a discussion.

  1. Gotta add tests to the main library at some point - probably once the core API design is hammered down a bit.
  2. I would love to have some sort of Jest plugin to help developers test their code. Maybe more of a e2e-targetted system as opposed to unit testing? Not sure how best to do this, but jest-discord gets a lot of traffic and having something like that from the get-go would be awesome.

Add support for multiple servers (Global Commands)

Describe the request
Currently, you can only have the commands registered on a single guild (specified in the .env).
It is not possible to use the same bot on multiple servers, which means that the library can't be used outside of testing.

Example Usage
One way to do it would be to set DEVELOPMENT_SERVER_ID to global, or by simple removing the variable from the .env entirely.

Additional context
N/A

Create Record Interface

We have a few ways of approaching API helpers - we could take each route and create a getRoleByID helpers, or we could create a standard Record interface that does something like this:

Role.fetch(id).edit({}).save()

Or something similar. It seems like people like this approach a little more, and we can easily build it on top of @leahlundqvist's API helpers and queue systems.

Incorrect typing for `interaction.options`

Describe the bug
Currently, interaction.options is typed as {}.
This causes TypeScript to throw an error (Property 'question' does not exist on type '{}').
Logging interaction.options to the console, you get {}.

Instead, it should be typed as

Record<string, string | number | boolean | User | Role | Channel>

To Reproduce

import { Command, StringInput } from 'interaction-kit';

export default new Command({
  name: '8ball',
  description: 'Ask the magic Eight Ball',
  options: [
    new StringInput({
      name: 'question',
      description: 'What do you want the Magic Eight Ball to answer?',
      required: true,
    }),
  ],
  handler: (interaction) => {
    interaction.reply({
      message: `> ${interaction.options.question}\n\n๐ŸŽฑ | Flip a coin lolol`, // TS error here
    });
  },
});

Additional context
I found the typings in node_modules\interaction-kit\dist\index.d.ts on line 459 , but I couldn't find them in the repository

Add `interaction-kit dev` Command

This command should load up environment secrets using dotenv and then execute the "main" file of the package.json file. Some of this logic will exist in the package itself rather than the cli, but the goal of this command is to enable command hot-reloading and auto-updating in the development server and output helpful log messages.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.