Skip to content

Commit 1bc0236

Browse files
Merge pull request #3 from Sxlitude/main
edited some code
2 parents 351a08c + e6ad8a1 commit 1bc0236

File tree

6 files changed

+99
-65
lines changed

6 files changed

+99
-65
lines changed

.replit

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
language = "nodejs"
2+
run = "node ."

commands/info/help.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
const Discord = require("discord.js");
21
const { MessageEmbed } = require("discord.js");
3-
const { Color, Prefix } = require("../../config.js");
2+
const { Color, Prefix } = require("../../index");
43

54
module.exports = {
65
name: "help",
@@ -11,22 +10,22 @@ module.exports = {
1110

1211
message.delete();
1312

14-
let embed = new MessageEmbed()
15-
.setColor(Color)
16-
.setTitle(`${client.user.username} Commands!`)
17-
.setDescription(`Use ${Prefix}Help <Command Name> For More Command Information!` +
13+
const embed = new MessageEmbed()
14+
.setColor(Color)
15+
.setTitle(`${client.user.username} Commands!`)
16+
.setDescription(`Use ${Prefix}Help <Command Name> For More Command Information!` +
1817
"`🔐`**Moderation**\n`Clear, Mute, Unmute, Tempmute, Kick,Unban, Tempban, Warn, Warnings, ResetWarns`" + "\n\n"+
1918
"`⌚`**Information**\n`Help")
20-
.setFooter(`Requested By ${message.author.username}`)
21-
.setTimestamp();
19+
.setFooter(`Requested By ${message.author.username}`)
20+
.setTimestamp();
2221

2322
if (!args.length) return message.channel.send(embed);
2423

2524
let cmd =
2625
client.commands.get(args[0].toLowerCase()) ||
2726
client.commands.get(client.aliases.get(args[0].toLowerCase()));
2827

29-
let embed2 = new MessageEmbed()
28+
const embed2 = new MessageEmbed()
3029
.setColor(Color)
3130
.setTitle(`${cmd.name} Information!`)
3231
.addField(`Aliases`, cmd.aliases || "None!")

index.js

+62-52
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,98 @@
1-
const Discord = require("discord.js");
1+
// Discord Library
2+
const { Client, Collection } = require('discord.js')
3+
const client = new Client();
4+
5+
// fs ffs!
26
const fs = require("fs");
3-
const client = new Discord.Client();
47
const { keep_alive } = require("./keep_alive");
5-
const { Prefix, Token, Color } = require("./config.js");
6-
client.commands = new Discord.Collection();
7-
client.aliases = new Discord.Collection();
8-
client.db = require("quick.db");
98

10-
client.on("ready", async () => {
11-
console.log(`DVS Tech Bot has Been Deployed!!`);
12-
client.user
13-
.setActivity(`$help`, { type: "LISTENING" })
14-
.catch(error => console.log(error));
15-
});
9+
// Parsing Settings
10+
const JSON5 = require('json5');
11+
const settings = JSON5.parse(process.env.settings)
1612

17-
client.on("message", async message => {
18-
if (message.channel.type === "dm") return;
19-
if (message.author.bot) return;
20-
if (!message.guild) return;
21-
if (!message.member)
22-
message.member = await message.guild.fetchMember(message);
13+
// Secret Vars
14+
const botToken = settings.bot.token;
15+
const botPrefix = settings.bot.prefix;
16+
const embedColor = settings.embeds.color;
2317

24-
if (message.content.match(new RegExp(`^<@!?${client.user.id}>`))) {
25-
return message.channel.send(`Bot Prefix : ${Prefix}`);
26-
}
27-
});
18+
// Exporting Secrets
19+
module.exports = {
20+
token: botToken,
21+
Prefix: botPrefix,
22+
Color: embedColor
23+
}
2824

29-
let modules = ["fun", "info", "moderation"];
25+
// Collection
26+
client.commands = new Collection();
27+
client.aliases = new Collection();
3028

31-
modules.forEach(function(module) {
32-
fs.readdir(`./commands/${module}`, function(err, files) {
33-
if (err)
34-
return new Error(
35-
"Missing Folder Of Commands! Example : Commands/<Folder>/<Command>.js"
36-
);
37-
files.forEach(function(file) {
38-
if (!file.endsWith(".js")) return;
39-
let command = require(`./commands/${module}/${file}`);
40-
console.log(`${command.name} Command Has Been Loaded - ✅`);
41-
if (command.name) client.commands.set(command.name, command);
42-
if (command.aliases) {
43-
command.aliases.forEach(alias =>
44-
client.aliases.set(alias, command.name)
45-
);
46-
}
47-
if (command.aliases.length === 0) command.aliases = null;
48-
});
49-
});
29+
// On Ready
30+
client.on("ready", () => {
31+
console.log(`[!]: The Bot is ready, logged in as ${client.user.tag}`);
32+
client.user.setActivity(`$help`, { type: "LISTENING" })
5033
});
5134

35+
// On Message
5236
client.on("message", async message => {
5337
if (message.channel.type === "dm") return;
5438
if (message.author.bot) return;
5539
if (!message.guild) return;
56-
if (!message.member)
40+
if (!message.member) {
5741
message.member = await message.guild.fetchMember(message);
42+
}
5843

44+
if (message.content.match(new RegExp(`^<@!?${client.user.id}>`))) {
45+
return message.channel.send(`Bot Prefix : ${Prefix}`);
46+
}
47+
const Prefix = botPrefix;
5948
if (!message.content.startsWith(Prefix)) return;
6049

6150
const args = message.content
6251
.slice(Prefix.length)
6352
.trim()
6453
.split(" ");
6554
const cmd = args.shift().toLowerCase();
66-
6755
if (cmd.length === 0) return;
6856

69-
let command =
70-
client.commands.get(cmd) || client.commands.get(client.aliases.get(cmd));
57+
let command = client.commands.get(cmd) || client.commands.get(client.aliases.get(cmd));
7158

7259
if (!command) return;
73-
7460
if (command) {
7561
if (!message.guild.me.hasPermission("ADMINISTRATOR"))
76-
return message.channel.send(
77-
"I Don't Have Enough Permission To Use This Or Any Of My Commands | Require : Administrator"
78-
);
62+
return message.channel.send("I Don't Have Enough Permission To Use This Or Any Of My Commands | Require : Administrator");
7963
command.run(client, message, args);
8064
}
8165
console.log(
8266
`User : ${message.author.tag} (${message.author.id}) Server : ${message.guild.name} (${message.guild.id}) Command : ${command.name}`
8367
);
8468
});
8569

86-
client.login(Token);
70+
const modules = ["fun", "info", "moderation"];
71+
72+
modules.forEach((module) => {
73+
fs.readdir(`./commands/${module}`, (err, files) => {
74+
if (err)
75+
return new Error(
76+
"Missing Folder Of Commands! Example : Commands/<Folder>/<Command>.js"
77+
);
78+
files.forEach((file) => {
79+
if (!file.endsWith(".js")) return;
80+
let command = require(`./commands/${module}/${file}`);
81+
console.log(`${command.name} Command Has Been Loaded - ✅`);
82+
if (command.name) client.commands.set(command.name, command);
83+
if (command.aliases) {
84+
command.aliases.forEach(alias =>
85+
client.aliases.set(alias, command.name)
86+
);
87+
}
88+
if (command.aliases.length === 0) command.aliases = null;
89+
});
90+
});
91+
});
92+
93+
client.login(botToken).catch((e) => { console.log(`the token is invalid!`) })
8794

88-
//Bot Coded by DVS Tech DONOT share WITHOUT credits!!
95+
/*
96+
Bot Coded by DVS Tech
97+
DONOT share WITHOUT credits!!
98+
*/

package-lock.json

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

package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010
"start": "node server.js"
1111
},
1212
"dependencies": {
13-
"express": "^4.17.1",
1413
"discord.js": "^12.3.1",
14+
"express": "^4.17.1",
15+
"figlet": "^1.5.0",
1516
"fs": "^0.0.2",
17+
"json5": "^2.2.0",
18+
"ms": "^2.1.2",
1619
"node-fetch": "^2.6.1",
17-
"figlet": "^1.5.0",
18-
"util": "^0.12.3",
1920
"novelcovid": "^3.0.0",
2021
"quick.db": "^7.1.1",
21-
"ms": "^2.1.2",
22+
"util": "^0.12.3",
2223
"weather-js": "^2.0.0"
2324
},
2425
"engines": {

test.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"bot": {
3+
"token": "",
4+
"prefix": ""
5+
},
6+
"embeds": {
7+
"color": ""
8+
}
9+
}

0 commit comments

Comments
 (0)