discord-context

1.5.0 • Public • Published

Discord Context

Build Status

A package that helps you create your Discord bots

Example

import { Client } from 'discord.js'
import Context from 'discord-context'
const bot = new Client()
 
bot.on('message', (message) => {
    // message = '!ban @username#4454 flood'
    const ctx = new Context(message)
 
    console.log(ctx.command) // ban
    console.log(ctx.args) // ["ban", "@username#3354"]
    console.log(ctx.message) // Discord.Message object
    console.log(ctx.mentions) // message.mentions
})

Using another separator and prefix

import { Client } from 'discord.js'
import Context from 'discord-context'
const bot = new Client()
 
bot.on('message', (message) => {
    // message = '//ban.@username#4454.flood'
    const ctx = new Context(message, {
        prefix: "//",
        separator: "."
    })
 
    console.log(ctx.command) // ban
    console.log(ctx.args) // ["ban", "@username#3354"]
    console.log(ctx.message) // Discord.Message object
    console.log(ctx.mentions) // message.mentions
})

Installation

$ npm i --save discord-context

Package Sidebar

Install

npm i discord-context

Weekly Downloads

0

Version

1.5.0

License

MIT

Unpacked Size

97 kB

Total Files

4

Last publish

Collaborators

  • webd