Skip to content

Commit

Permalink
Merge branch 'release/1.0.1'
Browse files Browse the repository at this point in the history
Release v1.0.1
  • Loading branch information
0xDevansh committed Dec 27, 2021
2 parents 16b1f80 + 46fbd7a commit 426f1f3
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 48 deletions.
64 changes: 50 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,66 @@ yarn add djs-marshal
npm install discord.js --save
```

## Quick Start
## Setup

In your root file, preferably index.js/ts, initialize the bot like so
You can set up your bot to handle commands in 2 ways:

```js
import Marshal from 'djs-marshal'
import { Intents } from "discord.js";
### initializeBot()

This is the recommended way to set up your bot. It sets up various things
like commands' directory, logging and handlers for various events required.

```ts
import Marshal from 'djs-marshal';
import path from 'path';

// https://deathvenom54.github.io/djs-marshal/modules.html#initializeBot
const client = Marshal.initializeBot({
intents: [Intents.FLAGS.GUILDS],
// you can pass in the token to make the client login
// automatically
token: 'your-token-here',
// this is the folder path that contains your commands
// the path where slash commands are stored
slashCommandsPath: path.join(__dirname, 'commands'),
// send all log messages
// (optional) message to log on ready event
readyMessage: 'Logged in as {tag}',
// (optional) bot's token, will login if provided
token: process.env.BOT_TOKEN,
// (default: 'warn') the level of logs to log in the console
logLevel: 'verbose',
// logs messages in a detailed manner
logStyle: 'expanded'
// (default: 'simple') how to style the logs
logStyle: 'extended',
});

// if you didn't provide the token above, log in yourself
// client.login(process.env.BOT_TOKEN);
```


### Doing it yourself

I don't recommend this, but if you want to, by all means you can set it up yourself.

```ts
import Marshal from './src/index';
import Discord from 'discord.js';
import path from 'path';

const client = new Discord.Client();

// load commands
Marshal.loadCommandsFromDir(path.join(__dirame, 'commands'));

// some parameters
client.logLevel = 'warn';
client.logStyle = 'simple';

// handlers
client.on('interactionCreate', Marshal.handlers.handleInteraction);
client.on('guildAdd', Marshal.handlers.handleGuildJoin);
// add this only if you have a command with allowWithPermission
client.on('guildMemberUpdate', Marshal.handlers.handleGuildMemberUpdate);

client.login(process.env.BOT_TOKEN);
```

## Commands

Now in your commands' folder, you can start creating command files!

Here are some examples:
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/search.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 426f1f3

Please sign in to comment.