Skip to content

Commit e25eae6

Browse files
committed
Fixes #76
1 parent 0d5dcae commit e25eae6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+196
-290
lines changed

.env.example

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# DataBase
2+
MONGO_URI=mongodb://127.0.0.1:27017/DBL
3+
4+
# Discord Server
5+
SERVER_ID=
6+
SERVER_INVITE=https://discord.gg/DvVgUtYFjw
7+
SERVER_MODLOG=
8+
SERVER_LIKELOG=
9+
SERVER_ADMINUSERS=["id1","id2"]
10+
SERVER_ROLE_BOT=1086322820868489227
11+
SERVER_ROLE_UNVERIFIED=
12+
SERVER_ROLE_VERIFIED=
13+
SERVER_ROLE_BOTDEVELOPER=
14+
SERVER_ROLE_BOTVERIFIER=
15+
16+
# Website Config
17+
WEBSITE_DOMAINWITHPROTOCOL=http://localhost
18+
WEBSITE_USEHTTPS=false
19+
WEBSITE_PORT=80
20+
WEBSITE_RATELIMIT=30
21+
WEBSITE_RECAPTCHA_PUBLIC=6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI
22+
WEBSITE_RECAPTCHA_PRIVATE=6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe
23+
24+
WEBSITE_BOTTAGS=[]
25+
WEBSITE_MAXBOTTAGS=6
26+
WEBSITE_MAXOWNERSCOUNT=4
27+
WEBSITE_MAXSUMMARYLENGTH=120
28+
WEBSITE_MINDESCRIPTIONLENGTH=200
29+
WEBSITE_MAXDESCRIPTIONLENGTH=500
30+
31+
# Discord Bot
32+
BOT_ID=
33+
BOT_SECRET=
34+
BOT_TOKEN=
35+
BOT_PREFIX=*

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
node_modules
2-
config.json
2+
.env

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
[![CodeFactor](https://www.codefactor.io/repository/github/thehelltower/discord-bot-list/badge)](https://www.codefactor.io/repository/github/thehelltower/discord-bot-list)
1414

1515
An open-sourced discord bot list.
16-
There's a [setup guide in the wiki](https://github.com/TheHellTower/Discord-Bot-List/wiki/Setup-Information) if you're interested. Put all the information in `config.json`.
16+
There's a [setup guide in the wiki](https://github.com/TheHellTower/Discord-Bot-List/wiki/Setup-Information) if you're interested. Put all the information in `.env`.
1717
The development branch may have newer additions/features, but is also potentially more buggy or even insecure. Use at your own risk.
1818
If you have any issues, check the [FAQs](https://github.com/TheHellTower/Discord-Bot-List/wiki/FAQs) first please.
1919

config-example.json

-41
This file was deleted.

package-lock.json

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"canvas-constructor": "^4.1.0",
3737
"cookie-parser": "^1.4.6",
3838
"discord.js": "^14.11.0",
39+
"dotenv": "^16.3.1",
3940
"ejs": "^3.1.9",
4041
"express": "^4.18.2",
4142
"express-rate-limit": "^6.7.0",

src/bot/commands/Bots/bots.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ const Command = globalThis.TheHellTower.client.structures.command;
22
const { EmbedBuilder } = require("discord.js");
33
const Bots = require("@models/bots");
44

5-
const {
6-
web: { domainWithProtocol },
7-
} = require("@root/config.json");
5+
const { WEBSITE_DOMAINWITHPROTOCOL } = process.env;
86

97
module.exports = class extends Command {
108
constructor(...args) {
@@ -39,9 +37,8 @@ module.exports = class extends Command {
3937

4038
if (bots.length === 0)
4139
return message.channel.send(
42-
`\`${user.tag}\` has no bots. Add one: <${domainWithProtocol}/add/>.`
40+
`\`${user.tag}\` has no bots. Add one: <${WEBSITE_DOMAINWITHPROTOCOL}/add>.`
4341
);
44-
console.log(bots.length);
4542
let cont = "";
4643
let un = false;
4744
for (let i = 0; i < bots.length; i++) {

src/bot/commands/Bots/marknsfw.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module.exports = class extends Command {
3131
if (
3232
!owners.includes(message.author.id) &&
3333
!message.member.roles.cache.has(
34-
globalThis.config.server.roleIds.botVerifier
34+
process.env.SERVER_ROLE_BOTVERIFIER
3535
)
3636
) {
3737
return message.reply(

src/bot/commands/Bots/queue.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ const Command = globalThis.TheHellTower.client.structures.command;
22
const { EmbedBuilder } = require("discord.js");
33
const Bots = require("@models/bots");
44

5-
const {
6-
server: { id },
7-
} = require("@root/config.json");
5+
const { SERVER_ID } = process.env;
86

97
module.exports = class extends Command {
108
constructor(...args) {
@@ -23,7 +21,7 @@ module.exports = class extends Command {
2321

2422
// No handling for a huge amount of bot ? Mmmmh...
2523
bots.forEach((bot) => {
26-
cont += `<@${bot.botid}> : [Invite](https://discord.com/oauth2/authorize?client_id=${bot.botid}&scope=bot&guild_id=${id}&permissions=0)\n`;
24+
cont += `<@${bot.botid}> : [Invite](https://discord.com/oauth2/authorize?client_id=${bot.botid}&scope=bot&guild_id=${SERVER_ID}&permissions=0)\n`;
2725
});
2826
if (bots.length === 0) cont = "Queue is empty";
2927

src/bot/commands/Bots/remove.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ const Command = globalThis.TheHellTower.client.structures.command;
22
const { EmbedBuilder } = require("discord.js");
33
const Bots = require("@models/bots");
44

5-
const {
6-
server: { modLogId, roleIds },
7-
} = require("@root/config.json");
5+
const { SERVER_MODLOG, SERVER_ROLE_BOTVERIFIER } = process.env;
86

97
const reasons = {
108
1: "Your bot was offline when we tried to verify it.",
@@ -46,7 +44,7 @@ module.exports = class extends Command {
4644
if (
4745
!owners.includes(message.author.id) &&
4846
!message.member.roles.cache.has(
49-
globalThis.config.server.roleIds.botVerifier
47+
SERVER_ROLE_BOTVERIFIER
5048
)
5149
) {
5250
return message.reply(
@@ -137,25 +135,25 @@ module.exports = class extends Command {
137135
.kick()
138136
.then(() => {})
139137
.catch((e) => {
140-
console.log(e);
138+
console.error(e);
141139
});
142140
})
143141
.catch((e) => {
144-
console.log(e);
142+
console.error(e);
145143
});
146144
} catch (e) {
147-
console.log(e);
145+
console.error(e);
148146
}
149147

150148
return m.edit({
151-
content: `Removed <@${bot.botid}> Check <#${modLogId}>.`,
149+
content: `Removed <@${bot.botid}> Check <#${SERVER_MODLOG}>.`,
152150
embeds: [],
153151
});
154152
}
155153
});
156154
}
157155

158156
async init() {
159-
modLog = await this.client.channels.fetch(modLogId);
157+
modLog = await this.client.channels.fetch(SERVER_MODLOG);
160158
}
161159
};

src/bot/commands/Bots/verify.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ const Command = globalThis.TheHellTower.client.structures.command;
22
const { EmbedBuilder } = require("discord.js");
33
const Bots = require("@models/bots");
44

5-
const {
6-
server: { modLogId, roleIds },
7-
} = require("@root/config.json");
5+
const { SERVER_MODLOG, SERVER_ROLE_BOTDEVELOPER, SERVER_ROLE_BOT, SERVER_ROLE_VERIFIED } = process.env;
86

97
let modLog;
108

@@ -34,7 +32,7 @@ module.exports = class extends Command {
3432
let owners = [bot.owners.primary].concat(bot.owners.additional);
3533
if (
3634
!message.member.roles.cache.has(
37-
globalThis.config.server.roleIds.botVerifier
35+
process.env.SERVER_ROLE_BOTVERIFIER
3836
)
3937
)
4038
return message.reply("Only DBL admin(s) are allowed to verify bots.");
@@ -79,21 +77,21 @@ module.exports = class extends Command {
7977

8078
owners = await message.guild.members.fetch({ user: owners });
8179
owners.forEach((o) => {
82-
o.roles.add(message.guild.roles.cache.get(roleIds.botDeveloper));
80+
o.roles.add(message.guild.roles.cache.get(SERVER_ROLE_BOTDEVELOPER));
8381
o.send(`Your bot \`${bot.username}\` has been verified.`).catch(() => {});
8482
});
8583
message.guild.members
8684
.fetch(message.client.users.cache.find((u) => u.id === bot.botid))
8785
.then((bot) => {
88-
bot.roles.add([roleIds.bot, roleIds.verified]);
86+
bot.roles.add([SERVER_ROLE_BOT, SERVER_ROLE_VERIFIED]);
8987
});
9088
return message.reply({
91-
content: `Verified <@${bot.botid}> Check <#${modLogId}>.`,
89+
content: `Verified <@${bot.botid}> Check <#${SERVER_MODLOG}>.`,
9290
embeds: [],
9391
});
9492
}
9593

9694
async init() {
97-
modLog = await this.client.channels.fetch(modLogId);
95+
modLog = await this.client.channels.fetch(SERVER_MODLOG);
9896
}
9997
};

src/bot/commands/Bots/widget.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ const Command = globalThis.TheHellTower.client.structures.command;
22
const https = require("https");
33
const Bots = require("@models/bots");
44

5-
const {
6-
web: { domainWithProtocol },
7-
} = require("@root/config.json");
5+
const { WEBSITE_DOMAINWITHPROTOCOL } = process.env;
86

97
module.exports = class extends Command {
108
constructor(...args) {
@@ -27,7 +25,7 @@ module.exports = class extends Command {
2725
user = user?.user ? user.user : user;
2826
if (!user || !user.bot)
2927
return message.channel.send("You didn't ping a bot to get a widget of.");
30-
const url = `${domainWithProtocol}/api/embed/${user.id}`;
28+
const url = `${WEBSITE_DOMAINWITHPROTOCOL}/api/embed/${user.id}`;
3129

3230
https
3331
.get(url, (res) => {
@@ -45,7 +43,7 @@ module.exports = class extends Command {
4543
});
4644
})
4745
.on("error", (err) => {
48-
console.log(`Error: ${err.message}`);
46+
console.error(`Error: ${err.message}`);
4947
});
5048
}
5149
};

src/bot/events/Client/messageCreate.js

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const Event = globalThis.TheHellTower.client.structures.event;
22

3-
const config = require("@root/config.json");
3+
const { BOT_PREFIX } = process.env;
44

55
module.exports = class extends Event {
66
constructor(...args) {
@@ -19,26 +19,23 @@ module.exports = class extends Event {
1919
const mentionRegex = RegExp(`^<@!?${this.client.user.id}>( |)$`);
2020
const mentionRegexPrefix = RegExp(`^<@!${this.client.user.id}> `);
2121

22-
const { prefix } = config.discordClient;
23-
2422
/// ////////////////////////////////////
2523
if (
2624
message.content.match(mentionRegex) ||
2725
message.content.match(mentionRegexPrefix)
2826
) {
29-
message.channel.send(`My prefix is \`${prefix}\` !`);
27+
message.channel.send(`My prefix is \`${BOT_PREFIX}\` !`);
3028
}
31-
if (!message.content.startsWith(prefix)) return;
29+
if (!message.content.startsWith(BOT_PREFIX)) return;
3230

3331
const [cmd, ...args] = message.content
34-
.slice(prefix.length)
32+
.slice(BOT_PREFIX.length)
3533
.trim()
3634
.split(/ +/g);
3735

3836
const command =
3937
this.client.commands.get(cmd.toLowerCase()) ||
4038
this.client.commands.get(this.client.aliases.get(cmd.toLowerCase()));
41-
// console.log(command);
4239

4340
if (command) {
4441
const data = {
@@ -50,14 +47,13 @@ module.exports = class extends Event {
5047

5148
async buildHelp(message) {
5249
const commands = await this.FetchCommands(message);
53-
const { prefix } = message.guildSettings;
54-
50+
5551
const helpMessage = [];
5652
for (const [category, list] of commands) {
5753
helpMessage.push(
5854
`**${category} Commands**:\n`,
5955
list
60-
.map(this.formatCommand.bind(this, message, prefix, false))
56+
.map(this.formatCommand.bind(this, message, BOT_PREFIX, false))
6157
.join("\n"),
6258
""
6359
);
@@ -68,7 +64,6 @@ module.exports = class extends Event {
6864

6965
async buildDisplay(message) {
7066
const commands = await this.FetchCommands(message);
71-
const { prefix } = message.guildSettings;
7267
const display = new RichDisplay();
7368
const color = message.member.displayColor;
7469
for (const [category, list] of commands) {
@@ -78,7 +73,7 @@ module.exports = class extends Event {
7873
.setColor(color)
7974
.setDescription(
8075
list
81-
.map(this.formatCommand.bind(this, message, prefix, true))
76+
.map(this.formatCommand.bind(this, message, BOT_PREFIX, true))
8277
.join("\n")
8378
)
8479
);
@@ -87,13 +82,13 @@ module.exports = class extends Event {
8782
return display;
8883
}
8984

90-
formatCommand(message, prefix, richDisplay, command) {
85+
formatCommand(message, BOT_PREFIX, richDisplay, command) {
9186
const description = isFunction(command.description)
9287
? command.description(message.language)
9388
: command.description;
9489
return richDisplay
95-
? `• ${prefix}${command.name}${description}`
96-
: `• **${prefix}${command.name}** → ${description}`;
90+
? `• ${BOT_PREFIX}${command.name}${description}`
91+
: `• **${BOT_PREFIX}${command.name}** → ${description}`;
9792
}
9893

9994
async FetchCommands(message) {

0 commit comments

Comments
 (0)