discord-context
v1.5.0
Published
A package that helps you create your Discord bots
Downloads
1
Readme
Discord Context
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