Skip to content

Commit dc0f3b1

Browse files
committed
Reworked, ready for release!
1 parent cd93d57 commit dc0f3b1

File tree

6 files changed

+46
-17
lines changed

6 files changed

+46
-17
lines changed

README.md

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
1-
# How to use
1+
# Discord Bots Stats
22

3-
> 1. Download the MultiBotProcessor.bat file.
4-
>
5-
> 2. Put all the bot tokens you want to use in ./data/tokens.js
3+
## About
64

7-
```js
8-
// This is the token format
9-
export default {
10-
botName: 'botToken',
11-
};
5+
This program can be used to save stats of a list of bots, as many as you want!
6+
7+
## How to use
8+
9+
All you need to do is it's initial [setup](#setup), or run the start.bat file. Everything else is done for you, once the script has finished your first data record can be found in [the data file](./data/data.json).
10+
11+
## Setup
12+
13+
You can run it once to have most of the setup done for you, however there is one thing you **must** do in order for the program to run.
14+
15+
After you ran it once you need to navigate to the [data folder](./data) and will see a [config.json](./data/config.json), if you don't see it, run the program once, or create it yourself.
16+
17+
In this config file you'll see the following boilerplate code:
18+
19+
```json
20+
{
21+
"rate":3600000,
22+
"guildId":"Insert Your Guild ID here",
23+
"tokens":{}
24+
}
1225
```
26+
If you don't see this, copy and paste the code into the config.json. Once you're there change the `guildId` to the guild that all your bots share, **ALL BOTS ARE MANDATORY TO JOIN THIS GUILD!**
1327

14-
> 3. Start the bat file.
28+
for tokens you'll just prefix the bot name and then it's token.
29+
```json
30+
{
31+
"BotName":"BotToken"
32+
}
33+
```

index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ const dataLog = JSON.parse(fs.readFileSync('./data/data.json', 'utf-8'));
2626

2727
log(`Updating ${bot} code`);
2828

29-
fs.writeFileSync(`./bots/${bot}.js`, `import { Client } from '../main.js';\nimport tokens from '../data/tokens.js';\n\nconst client = new Client();\nclient.login(tokens.${bot});`);
29+
fs.writeFileSync(
30+
`./bots/${bot}.js`,
31+
`import { Client } from '../main.js';\nimport config from '../data/config.json' assert {type:'json'};\n\nconst client = new Client();\nclient.login(config.tokens.${bot});`
32+
);
3033

3134
let { shards, stats } = new XernerxShardClient(`./bots/${bot}.js`, { token, respawn: true }, { log: { info: true } });
3235

main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class Client extends XernerxClient {
1818
},
1919
{
2020
global: false, // Whether the bot is loaded globally or locally
21-
local: config.guild, // The developer guild.
21+
local: config.guildId, // The developer guild.
2222
log: {
2323
ready: true, // Log when the bot is ready and logged in.
2424
error: true, // Log when an internal error occurs.

models/log.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ const start = Number(Date.now());
44
export default function log(message, type = 'info') {
55
const ram = Math.round(process.memoryUsage().rss / 1000000);
66

7-
const string = `${new Date().toLocaleTimeString()} | ${Number(Date.now()) - start}ms. | ${ram}MB.`;
7+
const string = `${Style.log(new Date().toLocaleTimeString(), { color: Style.TextColor.Yellow })} | ${Style.log(Number(Date.now()) - start, { color: Style.TextColor.LightBlue })}ms | ${Style.log(
8+
ram,
9+
{ color: Style.TextColor.LightGreen }
10+
)}MB`;
811

912
if (type == 'error') {
10-
console.error(`${Style.log(`❗ | Stats`, { color: Style.TextColor.Red })} | ${string} | ${message}`);
13+
console.error(`${Style.log(`❗ | Stats`, { color: Style.TextColor.Red })} | ${string} | ${Style.log(message, { color: Style.TextColor.LightGrey })}`);
1114
} else {
12-
console.info(`${Style.log(`✔️ | Stats`, { color: Style.TextColor.Purple })} | ${string} | ${message}`);
15+
console.info(`${Style.log(`✔️ | Stats`, { color: Style.TextColor.Purple })} | ${string} | ${Style.log(message, { color: Style.TextColor.LightGrey })}`);
1316
}
1417
}

models/setup.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const config = JSON.stringify({
1212
(async () => {
1313
const shell = promisify(exec);
1414

15+
await shell('mkdir data').catch(() => true);
16+
1517
const dir = fs.readdirSync('./data');
1618

1719
log('Installing dependencies...');
@@ -42,6 +44,8 @@ const config = JSON.stringify({
4244
if (!dir.includes('config.json')) {
4345
log('Config file not existant, creating one.', 'error');
4446
await shell(`echo ${config} > ./data/config.json`);
47+
48+
log('Navigate over to ./data/config.json and add your bots and tokens and the local guild id!');
4549
} else log('Config file found!');
4650

4751
log('Finished building files!');
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ if "%git%" == "true" (
3030

3131
echo Updating to latest git version...
3232

33-
34-
3533
git clone https://github.com/PortalDiscordDevelopment/DiscordBotStats .
3634

3735
echo Finished updating to latest git version.
3836

37+
call npm i
38+
3939
call node ./models/setup.js
4040

4141
:loop

0 commit comments

Comments
 (0)