A flexible framework for creating a Discord bot in Typescript.
yarn add discorb discord.js
import { Bot } from 'discorb'
import { Client } from 'discord.js'
const bot = new Bot({ prefix: ';;' })
// ;;ping
// ;;ping This will also be returned
.register('ping', (request) => {
request.message.reply(
request.args.length > 0
? `Pong! (with args: ${request.args.map((a) => `\`${a}\``).join(' ')})`
: 'Pong!'
)
})
// ;;ping --help
.help(
'ping',
`Responds with "Pong!" as well as returning any additional arguments.`
)
// ;;ping pong
.register('ping pong', (request) => {
request.message.reply('Ping pong!')
})
// ;;ping pong --help
.help('ping pong', 'Just says ping pong! Simple as that!')
if (process.env.DISCORD_LOGIN == undefined) {
throw new Error('Please provide a DISCORD_LOGIN env variable')
} else {
const client = new Client()
client.login(process.env.DISCORD_LOGIN)
bot.listen(client)
}
process.on('exit', () => {
bot.close()
})
For more, take a look at the examples directory.
This project uses the following license: Hippocratic v2.1.
Bot state type
Message or message generator to be displayed when <prefix><command> --help
or <prefix>help
is called
Bot state type
Message displayed when <prefix><command> --help
or <prefix>help
is called
For use with Bot.setState. Either the entire state or a subset of it.
Bot state type
Keys of the bot state
Listener for state changes.
Bot state type
Function is bound to the bot instance. Not an actual param.
The previous state of the bot before the update.
The current, updated state of the bot.
Generated using TypeDoc
Callback function for commands.