- Table of Contents
- TwistyBot
- Discord.js extensions
- extension: Channel
- extension: Guild
- extension: GuildMember
- extension: Message
- extension: User
- extension: Markdown Functions
- Discord.italics(text)
- Discord.bold(text)
- Discord.bold_italics(text)
- Discord.strikeout(text)
- Discord.underline(text)
- Discord.underline_italics(text)
- Discord.underline_bold(text)
- Discord.underline_bold_italics(text)
- Discord.code_block(text)
- Discord.inline_code(text)
- Discord.link(link)
- Discord.masked_link(text, link)
- Discord.json(value)
const TwistyBot = require('twistybot');
let bot = new TwistyBot.Client();
(async function() {
// Register default commands
await bot.add_default_commands();
// Register a folder of commands
await bot.add_command_directory(__dirname + '/commands');
// Begin listening for commands
bot.login('your bot token');
})();
- extends: Discord.Client
-
options
<Object>help
<?Object>params
<?Object>permissions
<Array<Object>>aliases
<?Array<String>> A list of aliases for this command.name
<String> The name of this command.category
<String> The category of this command.init
<Function> A function called to initialize any data the command uses.run
<Function> The main command function that prepares the command response.
-
returns: <Promise> Resolves when TwistyBot finishes initializing the command.
-
folder
<String> Path to a folder of commands -
returns: <Promise> Resolves when TwistyBot finishes initializing all commands in the folder.
This function provides a convenient way to load an organized folder of commands, with the following structure:
folder
├category1
│ ├command1.js
│ ├command2.js
│ └command3.js
└category2
└command4.js
Subfolders are treated as command categories, with the name of the subfolder used as the category name. Files within the subfolder should export command options that can be passed to Client.add_command(). The filename will automatically be used as the command name, excluding the file extension. An example command folder can be found at /src/commands, which contains TwistyBot's default commands.
- returns: <Promise> Resolves when TwistyBot finishes initializing the commands.
Adds the default commands. The default commands include help
, permission
, and setprefix
.
- returns: <?Command>
Finds a command by its name or alias. If no such command exists, this function returns undefined.
err
<Error> The error that was raised.message
<Discord.Message> The command message that was being processed.
This function delivers a stack trace of the error to the bot's Discord error channel. You can specify this channel by passing a channel ID to the bot constructor:
let bot = new TwistyBot.Client({
error_channel: '212345627062207890'
});
- returns: <Promise>
- returns: <Object>
- returns: <undefined>
Clears the usage/error statistics for this command.
-
prefix
<String> The command prefix to use in examples and usage. -
returns: <String> The formatted help text
- returns: <Promise> Resolves when all keys are cleared
theme
<?String> Specifies the theme of the table. There are two built-in themes: 'default' and 'borderless'.
-
a
<String> Specifies the alignments of each column. Valid characters are 'l' for left, 'r' for right, and 'c' fo center aligned. For example, 'llr' indicates the first two columns are left aligned, and the third column is right aligned. -
returns: <undefined>
-
row
A row of table values. -
returns: <undefined>
This function adds a new row of values to the bottom of the table.
-
row
A row of table values. -
returns: <undefined>
This function adds a new row of center aligned values to the bottom of the table. A separator is added automatically after the row is inserted.
-
value
A single value. -
returns: <undefined>
This function adds a full width, centered row to the bottom of the table.
- returns: <undefined>
This function adds a separator between the bottom row and the next row pushed.
- returns: <undefined>
This function removes the most recently pushed row.
- returns: <undefined>
This function removes all rows from the table.
- returns: <String>
Stringifies the table. Does not add Discord code block tags.
- returns: <Number> The number of rows in the table.
- returns: <Number> The number of columns in the table.
TwistyBot adds some extra functionality to the base Discord.js features. That is to say, you can access all the functions and variables of the original Discord.js classes, plus these additional functions defined by TwistyBot.
- extends: Discord.Channel
- returns: <String> A friendly name for the channel. For example, a DM channel with user#1234 would be returned as
DM.user#1234
.
- extends: Discord.Guild
- returns: <Config> Settings for this guild.
- extends: Discord.GuildMember
- returns: <Config> Settings for this user.
- extends: Discord.Message
- returns: <String> A string representation of the message content. Embeds and file attachments are also stringified after the main message text content.
- extends: Discord.User
- returns: <Config> Settings for this user.
The following are convenience functions for using Discord Markdown. They are made available as properties of the Discord.js module.
const TwistyBot = require('twistybot');
const Discord = require('discord.js');
console.log( Discord.bold('Hello world!') );
text
<String> Text to format- returns: <String> Text formatted with bold and italics markdown:
***text***
text
<String> Text to format- returns: <String> Text formatted with underline and italics markdown:
__*text*__
text
<String> Text to format- returns: <String> Text formatted with underline and bold markdown:
__**text**__
text
<String> Text to format- returns: <String> Text formatted with underline, bold, and italics markdown:
__***text***__
This function formats a link so that it does not automatically embed a preview of the url after the message.
Masked links display the given text instead of the url, allowing for nicer output. Masked links can only be used inside embeds, not regular text messages. Note that masked links are referred to as "spoopy links" within Discord.
value
Value to be formatted- returns: <String>
A shortcut for making a JSON language code block using the stringified value.