Code Monkey home page Code Monkey logo

symbux / turbo-discord Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 325 KB

A Discord plugin that expands the Turbo engine to be able to work with and manage Discord bots, SSO with Discord and more using customised command controllers, with latest support for slash commands, buttons, select menus, autocomplete, events, modals and more.

License: Apache License 2.0

JavaScript 5.83% TypeScript 94.17%
api bot-framework discord discord-bot discord-js turbo

turbo-discord's People

Contributors

dannysmc95 avatar

Watchers

 avatar

turbo-discord's Issues

Create embed builder.

Implement some function similar to: context.createEmbed that will allow for creating embeds, without having to import the MessageEmbed everytime, additionally, would be good to automate things like strip indents, and other utility functions.

AnyMessageComponentBuilder

I need to re-look into the action row stuff for the discord, since the v14 update, there are issues with how it handles buttons, and in the pioneers project, I am getting issues passing it buttons, need to fix that.

Add support for autocomplete.

This is to add support for autocomplete for string/number fields.

The suggested structure is as follows, each option is given a name, for example for a to-do list, you may have a remove method which can be used to lookup the available tasks to remove.

To do this, we would want to support, general catch all's where the context can be given appropriately but you can control how you want to access each autocomplete, and then additionally lower level so you can say which option and which subcommand if applicable.

To do this, we shall add a new method decorator as: @On.Autocomplete the parameters would be:

  • optionName - An optional parameter that defaults to *, but if passed will only allow autocomplete for that specific option name.
  • subCommand - An optional parameter, again defaulting to * that will verify if a subcommand is there, then only allow that.

By default all autocompletions would be managed inside of a command class, and would be processed under that command, so if you had 3 different commands, you would need at the minimum, 3 autocomplete commands inside of each command class.

An example of the above may look like:

Assume the below method would be part of the TodoCommand class.

@On.Autocomplete()
public async onAutocomplete(context: Context): Promise<void> {
  const interaction = context.getInteraction<CommandInteraction>();
  const query = interaction.options.getFocused() as string;

  interaction.respond(
    this.tasks.filter(task =>

      // If no query, return all.
      if (!query || String(query).length === 0) return true;

      // Otherwise filter against name matches.
      return task.name.toLowerCase().includes(query.toLowerCase());
    })
    .map(task => {
      return {
        name: task.name,
        value: task.id,
      };
    });
  );
}

Add better options collector with defaults.

The ability here is to support an easier way of getting options, can we remove the need for ever using the interaction object?

The functionality would work like as follows:

  • context.getOptions() - This would find and get all options and turn them into an array where you would have the option name, the value, and type.
  • context.getOption<Type>(optionName, default) - This would get a specific option with a default.
  • context.getXOption(optionName, default) - The X here would be the type, so you could do: context.getStringOption still supporting defaults.

It's worth noting sometimes options will DEFINITELY be there, and therefore, we may want to add some kind of other call method to work with either.

Add context menu support.

To add context menu support, for right clicking a user, or right clicking a message.

In most cases your context menu will be linked to a command, taking a to-do example, if you wanted to support taking any message and turning it into a task, then being able to right click and "Add To To-Dos" would be a great use case. So by doing so we can assume each context menu option will only need to handle a single thing, meaning we would prefer to use method decorators vs. a whole class for a single command, additionally, you can define context menu's in your command, as that logic may share functionality without having to externalise certain functionality into a provider if no reason to.

To do this we would need to create some new decorators, proposed instead of the event handlers which start as @On.X we would use @Add.* where the two available context menu's are:

  • MessageContext - This will take a name, and automatically deploy and create a message context menu which would work on right click of a message.
  • UserContext - This will take a name, and automatically deploy and create a user context menu which would work on right click of a user.

Using the above example a snippet may look like:

@Add.MessageContext('Add as Task')
public async onAddTaskContext(context: Context): Promise<void> {
    // Do stuff here...
}

Additionally, I am aware all context menu options may not be linked to a specific command and therefore moving forward with preferring grouping, we shall make a generic @ContextMenu class decorator, that will allow classes to be processed by the service, allowing you to use the @Add.X method decorators to group up context functionality.

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.