Skip to content

Commit 93fbe40

Browse files
committed
UPDATE
1 parent eac9481 commit 93fbe40

File tree

13 files changed

+81
-62
lines changed

13 files changed

+81
-62
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
- **Project built on `discord.js` v14.**
44
- **Minimum required Node.js version: v16.11.**
5-
- **Example command setup can be found in [`src/commands/info/ping.js`](https://github.com/memte/ExampleBot/blob/v14/src/commands/info/ping.js).**
5+
- **Example command setup can be found in [`src/Commands/info/ping.js`](https://github.com/memte/ExampleBot/blob/v14/src/Commands/info/ping.js).**
6+
- **Don't forget to prepare a .env file in the same way as in [`example.env`](https://github.com/memte/ExampleBot/blob/v14/example.env)!**
67
For more details, visit the [Discord.js Guide](https://discordjs.guide/slash-commands/advanced-creation.html).
78

8-
- **Note: Remember to configure your settings in the [`config.js`](https://github.com/memte/ExampleBot/blob/v14/src/config.js) file.**
9+
- **Note: Remember to configure your settings in the [`config.js`](https://github.com/memte/ExampleBot/blob/v14/src/Base/config.js) file.**
910

1011
## 🌟 Support the Project
1112

example.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
BOT_TOKEN=""

package.json

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
{
2-
"scripts": {
3-
"start": "node index.js"
4-
},
5-
"type": "module",
6-
"license": "MIT",
7-
"dependencies": {
8-
"discord.js": "^14.16.3",
9-
"fs": "^0.0.2",
10-
"lodash.uniqwith": "^4.5.0",
11-
"moment": "^2.30.1"
12-
},
13-
"engines": {
14-
"node": ">=16.11.0"
15-
}
16-
}
1+
{
2+
"scripts": {
3+
"start": "node src/Base/app.js"
4+
},
5+
"type": "module",
6+
"license": "MIT",
7+
"dependencies": {
8+
"discord.js": "^14.16.3",
9+
"dotenv": "^16.4.5",
10+
"fs": "^0.0.2",
11+
"lodash.uniqwith": "^4.5.0",
12+
"winston": "^3.15.0"
13+
},
14+
"engines": {
15+
"node": ">=16.11.0"
16+
}
17+
}
Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
import {Client, GatewayIntentBits, Partials} from 'discord.js';
2-
const client = new Client({
3-
intents: Object.values(GatewayIntentBits),
4-
partials: Object.values(Partials),
5-
shards: 'auto',
6-
});
7-
import config from './src/config.js';
8-
import {readdirSync} from 'node:fs';
9-
10-
const {token} = config;
11-
12-
readdirSync('./src/utils').forEach(async file => {
13-
const utilFile = await import(`./src/utils/${file}`);
14-
const util = utilFile.default;
15-
util.execute(client);
16-
});
17-
18-
client.login(token);
1+
import {Client, GatewayIntentBits, Partials} from 'discord.js';
2+
const client = new Client({
3+
intents: Object.values(GatewayIntentBits),
4+
partials: Object.values(Partials),
5+
shards: 'auto',
6+
});
7+
import {readdirSync} from 'node:fs';
8+
import dotenv from "dotenv";
9+
dotenv.config();
10+
11+
const token = process.env.BOT_TOKEN;
12+
13+
readdirSync('./src/Handlers').forEach(async file => {
14+
const utilFile = await import(`../Handlers/${file}`);
15+
const util = utilFile.default;
16+
util.execute(client);
17+
});
18+
19+
client.login(token);

src/Base/config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default {
2+
prefix: '!',
3+
owners: ["Owner ID"]
4+
};
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ export default {
99
client.slashDatas = [];
1010

1111
// - Handlers -
12-
const commandFolders = await readdirSync('./src/commands');
12+
const commandFolders = await readdirSync('./src/Commands');
1313

1414
await Promise.all(commandFolders.map(async category => {
15-
const commandFiles = await readdirSync(`./src/commands/${category}`);
15+
const commandFiles = await readdirSync(`./src/Commands/${category}`);
1616

1717
await Promise.all(commandFiles.map(async file => {
18-
const commands = await import(`../commands/${category}/${file}`);
18+
const commands = await import(`../Commands/${category}/${file}`);
1919

2020
if (commands) {
2121
if (commands.commandBase) {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import {readdirSync} from 'node:fs';
22

33
export default {
44
async execute(client) {
5-
const eventFiles = readdirSync('./src/events');
5+
const eventFiles = readdirSync('./src/Events');
66

77
Promise.all(eventFiles.map(async file => {
8-
const event = await import(`../events/${file}`).then(x => x.default);
8+
const event = await import(`../Events/${file}`).then(x => x.default);
99

1010
if (event.once) {
1111
client.once(event.name, (...args) => event.execute(...args));

src/Handlers/logger.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import winston from 'winston';
2+
3+
export default {
4+
async execute(client) {
5+
client.logger = winston.createLogger({
6+
level: "info",
7+
format: winston.format.combine(
8+
winston.format.timestamp({
9+
format: "DD-MM-YYYY HH:mm:ss",
10+
}),
11+
winston.format.printf(
12+
(info) => `[${info.timestamp}] ${info.level}: ${info.message}`,
13+
),
14+
),
15+
transports: [
16+
new winston.transports.Console({
17+
format: winston.format.combine(
18+
winston.format.colorize(),
19+
winston.format.simple(),
20+
),
21+
}),
22+
],
23+
});
24+
},
25+
};

src/config.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/events/interactionCreate.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Collection, Events, InteractionType} from 'discord.js';
2-
import config from '../config.js';
2+
import config from '../base/config.js';
33
const cooldown = new Collection();
44

55
export default {
@@ -13,8 +13,8 @@ export default {
1313

1414
try {
1515
const command = client.slashCommands.get(interaction.commandName);
16-
if (command.ownerOnly && interaction.user.id !== config.owner) {
17-
return interaction.reply({content: 'Only my **developer** can use this command.', ephemeral: true});
16+
if (command.ownerOnly && !config.owners.includes(interaction.user.id)) {
17+
return interaction.reply({content: 'Only my **developers** can use this command.', ephemeral: true});
1818
}
1919

2020
if (command.cooldown) {

0 commit comments

Comments
 (0)