From 9e5cdb196823ab540dd19b2f4186889d302fec18 Mon Sep 17 00:00:00 2001 From: spuckhafte Date: Wed, 13 Sep 2023 16:40:06 +0530 Subject: [PATCH] ::new:: => custom intents --- README.md | 7 +++++-- dist/index.d.ts | 2 ++ dist/index.js | 4 ++-- package.json | 2 +- src/index.ts | 7 ++++--- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index fe859d7..598657d 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,8 @@ import { Bot } from 'breezer.js' const bot = new Bot({ token: "", prefix: "+", - commandsFolder: "commands" + commandsFolder: "commands", + // intents: [] }); bot.go(() => console.log('Logged In')); @@ -43,9 +44,11 @@ It is as easy as its looks.
Everything else looks quite easy to follow up.
Fill up some details and you're ready to *go()* !
+*Note: There is also an [optional] property to have custom intents (Breezer automatically sets the most common ones by default)*. + **`commands/ping.js` :** ```js -import { Command } from 'breezer.js/dist' +import { Command } from 'breezer.js' export default class extends Command<[]> { constructor() { diff --git a/dist/index.d.ts b/dist/index.d.ts index e5b42c4..a18ec85 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -6,6 +6,7 @@ declare class Bot { commands: string[]; bot: discord.Client; prefix: string; + intents?: number[]; private commandObjects; private token; private cmdFolder; @@ -15,6 +16,7 @@ declare class Bot { token: string; prefix: string; lang: '.js' | '.ts'; + intents?: number; }); go(cb?: CallableFunction): Promise; } diff --git a/dist/index.js b/dist/index.js index 583e3ea..d8a1799 100644 --- a/dist/index.js +++ b/dist/index.js @@ -15,13 +15,13 @@ import { StateManager } from './helpers/stateManager.js'; import { buttonSignal, getIntents, userHasPerm } from './helpers/funcs.js'; class Bot { constructor(options) { - let intents = getIntents(); + var _a; this.commands = fs.readdirSync(options.commandsFolder).map(i => i.replace(options.lang, '')); this.token = options.token; this.cmdFolder = options.commandsFolder; this.prefix = options.prefix; this.lang = options.lang; - this.bot = new discord.Client({ intents }); + this.bot = new discord.Client({ intents: (_a = this.intents) !== null && _a !== void 0 ? _a : getIntents() }); let cmdsCollectd = {}; for (let command of this.commands) { const cmdPath = `file://${process.cwd()}/${this.cmdFolder}/${command}${this.lang}`; diff --git a/package.json b/package.json index eae1f28..4b30d2e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "breezer.js", - "version": "0.5.0", + "version": "0.5.1", "description": "", "main": "dist/index.js", "scripts": { diff --git a/src/index.ts b/src/index.ts index 6272bd0..ae2d127 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,13 +10,14 @@ class Bot { commands:string[]; bot:discord.Client; prefix:string; + intents?: number[]; + private commandObjects:{ [index: string]: TypicalCommand<[]> }; private token:string; private cmdFolder:string; private lang:string - constructor(options:{ commandsFolder:string, token:string, prefix:string, lang:'.js'|'.ts' }) { - let intents = getIntents(); + constructor(options:{ commandsFolder:string, token:string, prefix:string, lang:'.js'|'.ts', intents?: number }) { this.commands = fs.readdirSync(options.commandsFolder).map(i => i.replace(options.lang, '')); this.token = options.token; @@ -24,7 +25,7 @@ class Bot { this.prefix = options.prefix; this.lang = options.lang; - this.bot = new discord.Client({ intents }); + this.bot = new discord.Client({ intents: this.intents ?? getIntents() }); let cmdsCollectd:{ [index: string]: TypicalCommand<[]> } = {}; for (let command of this.commands) {