Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/aiden01/discord-context

A lightweight package that helps you create your Discord bots
https://github.com/aiden01/discord-context

discord-js javascript npm-package

Last synced: 7 days ago
JSON representation

A lightweight package that helps you create your Discord bots

Awesome Lists containing this project

README

        

# Discord Context
[![Build Status](https://travis-ci.com/Webd01/Discord-Context.svg?branch=master)](https://travis-ci.com/Webd01/Discord-Context)

A package that helps you create your Discord bots

# Example

```js
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

```js
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
```bash
$ npm i --save discord-context
```