msg.ts
TypeScript icon, indicating that this package has built-in type declarations

0.5.0 • Public • Published

MSG


Discord npm Build Status npm Lines of code NPM


MSG is a powerful, adaptable and complementary framework for building discord bot applications

Table of contents

About

MSG is a discord bot framework that made for complement discord.js library.

it runs on discord.js base, but it can do a lot of things to easy, than discord.js does.

so, MSG can provide legacy workload that base on discord.js library.

also, MSG can help you more with repetitive and meaningless tasks such as separation and controlling commands.

Installation

Node.js 16.0.0 or newer is required.

npm i msg.ts

Usage

const MSG = require('msg.ts')

const prefix = '!'

const bot = new MSG.Bot()

bot.setConfig({
    prefix,
})

bot.on('readyState', bot => {
    console.log(`${bot.user.tag} is ready!`)
})

bot.indent('now', [
    MSG.subCall('day', ctx => {
        ctx.reply(
            `current day is \`${new Intl.DateTimeFormat('en-US', {
                weekday: 'long',
            }).format(new Date().getDay())}\``,
        )
        return ctx.finish()
    }),
    MSG.subCall('date', ctx => {
        ctx.reply(`today is the \`${new Date().getDate()}th\``)
        return ctx.finish()
    }),
    MSG.subCall(true, ctx => {
        ctx.reply(`now time is \`${new Date()}\``)
        return ctx.finish()
    }),
])

bot.addCommand(
    MSG.subCall(true, ctx => {
        const commandDoc = `now:
    usage: \`${prefix}now\`
    description: show current time
    subcommands:
        name: day
            usage: \`${prefix}now day \`
            description: show current day of week
        name: date
            usage: \`${prefix}now  date\`
            description: show current date
        <default>
            description: just show all data
            usage: \`${prefix}now\``

        ctx.reply(`command list:\n\`\`\`yml\n${commandDoc}\n\`\`\``)
        return ctx.finish()
    }),
)

bot.login(process.env.DISCORD_TOKEN)

Other packages

generator-msg scaffolding for MSG framework (npm i -g yo generator-msg ; yo msg)

Contributing

are you want to contribute?

thanks so much!

please read our contributing guide before start contribute

links

Dependents (0)

Package Sidebar

Install

npm i msg.ts

Weekly Downloads

0

Version

0.5.0

License

MIT

Unpacked Size

190 kB

Total Files

79

Last publish

Collaborators

  • abiria