Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/aiden01/discord-context
- Owner: Aiden01
- Created: 2018-08-29T13:45:04.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-03T02:44:26.000Z (about 6 years ago)
- Last Synced: 2024-11-12T17:49:31.040Z (8 days ago)
- Topics: discord-js, javascript, npm-package
- Language: JavaScript
- Homepage:
- Size: 32.2 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
```