-
Notifications
You must be signed in to change notification settings - Fork 0
Helpers
The framework has some built in helpers, including sessions, oauth, and promise queues, but these are covered in the other sections, in this section we go over the additional helpers from within the context, AND the misc, there are only a few but as time goes on, more will be added
To start with, we always suggest looking at the source code, as it's fully commented and easy to follow, but we will outline some methods available from the context returned.
This method will return the user that ran the command, this will get an instance of the User
class NOT the GuildMember
for that see getGuildMember
.
This method will return the guild that the command was ran in, this will get an instance of the Guild
class.
This method will return the guild member that the command was ran in, this will get an instance of the GuildMember
class NOT the user class, see the getUser
method from above.
This method will return the channel that the command was ran in, this will get an instance of the TextBasedChannel
class.
This method will run the defer method, so that your application has more time to respond, with an option to set the response as ephemeral.
This method will accept a series of permissions and check whether the user has all or the single permission given.
This method will accept a series of role names, and check them against the user, all must be assigned to the user.
This method will return the Client
bot class instance for the underlying discord.js client.
This method will attempt to find a user by ID, and return the User
class, see next method for getting a GuildMember
.
This method will attempt to find a guild member by ID, and return the GuildMember
class instance.
This method will get the interaction, due to the context being used for all interactions (command, button, select menu) you can use a generic to set the return type, like so: context.getInteraction<ButtonInteraction>();
.
This method works in the same idea as window.confirm
in web development, where you can pass it a string and some options and it will ask the user a question of yes or no and capture the response, using collectors, meaning you can await and ask many questions at once.
This method will work similar to the confirm function but ask for a selection from a list of options, this is not yet implemented and will be in the next version.
Context.createActionRow(...components: MessageActionRowComponentResolvable[] | MessageActionRowComponentResolvable[][])
This method is a simple short hand helper for creating action rows.
This method is a simple short hand helper for creating buttons, primarily for quick access and working with the context.createActionRow
method.
This method is a promisifed wait method for waiting a certain amount of time, it was created for testing certain functionality but can be used for anything, including animations or other.
import { Misc } from '@symbux/turbo-discord';
async function test() {
console.log('Started');
await Misc.Wait(5000);
console.log('Done');
}
This method is a simple generate key function for generating a random key of a certain length, it is used for generating keys for things like sessions, and other things.
import { Misc } from '@symbux/turbo-discord';
console.log(Misc.GenerateKey(10));
Home | Turbo Engine | GitHub | NPM
- Configuration
- Creating Commands
- Adding Autocomplete
- Adding Context Menu
- Middleware Setup
- Built-In Helpers
- Promise Queue
- Command Sessions
- Setting Up OAuth
- Turbo Engine Github
- Need your own plugin? Contact Me
- Have an idea? Let's Discuss
- Want to support me? Buy me a coffee