Skip to content

Commit

Permalink
::new:: => custom intents
Browse files Browse the repository at this point in the history
  • Loading branch information
spuckhafte committed Sep 13, 2023
1 parent 271046d commit 9e5cdb1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import { Bot } from 'breezer.js'
const bot = new Bot({
token: "<BOT_TOKEN>",
prefix: "+",
commandsFolder: "commands"
commandsFolder: "commands",
// intents: []
});

bot.go(() => console.log('Logged In'));
Expand All @@ -43,9 +44,11 @@ It is as easy as its looks.<br>
Everything else looks quite easy to follow up.<br>
Fill up some details and you're ready to *go()* !<br>

*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() {
Expand Down
2 changes: 2 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ declare class Bot {
commands: string[];
bot: discord.Client;
prefix: string;
intents?: number[];
private commandObjects;
private token;
private cmdFolder;
Expand All @@ -15,6 +16,7 @@ declare class Bot {
token: string;
prefix: string;
lang: '.js' | '.ts';
intents?: number;
});
go(cb?: CallableFunction): Promise<void>;
}
Expand Down
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "breezer.js",
"version": "0.5.0",
"version": "0.5.1",
"description": "",
"main": "dist/index.js",
"scripts": {
Expand Down
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@ 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;
this.cmdFolder = options.commandsFolder;
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) {
Expand Down

0 comments on commit 9e5cdb1

Please sign in to comment.