Skip to main content

Custom Context

Erine advanced let's you implement a custom context for your commands.

Create your class

const { Context } = require("erine");

class CustomContext extends Context {
get branch() {
return "advanced"
}
}

Add your class into the client constructor

const { Erine } = require('erine'); // for TypeScript use: import { Erine } from 'erine'; 

const bot = new Erine({
auth: "Bot BOT TOKEN HERE",
gateway: {
intents: [...intents]
},
context: CustomContext
});

Use it in your commands

const { Maker, Command } = require("erine");

class Branch extends Maker {
@Command({ name: "branch", aliases: ["version"] })
async ping(context) {
await context.send("Erine branch: " + context.branch);
}
}

module.exports = { data: Branch }; // Important to export the class as "data".