Skip to content

Commit 1c004a9

Browse files
committed
v1.3.0
1 parent a6ad0f0 commit 1c004a9

File tree

11 files changed

+626
-493
lines changed

11 files changed

+626
-493
lines changed

commands/helloworld.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
const Command = require("../structures/command.js");
2-
const { red } = require('chalk');
3-
const embeds = require('../utils/embeds.js');
42

53
module.exports = new Command({
64
name: "hello",
@@ -9,12 +7,9 @@ module.exports = new Command({
97

108
async run(message, args, client) {
119
try {
12-
13-
message.reply("Hello world!");
14-
10+
message.reply("Hello World!");
1511
} catch (error) {
16-
embeds.errorEmbed(client, message, "Something went wrong.");
17-
console.log(red(`[COMMAND] In the command ${this.name} an error has occurred -> ${error}`))
12+
console.log(error);
1813
}
1914
}
2015
});

commands/reload.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const Command = require("../structures/command.js");
2+
const Discord = require("discord.js");
3+
const fs = require("fs");
4+
const chalk = require('chalk');
5+
6+
module.exports = new Command({
7+
name: "reload",
8+
description: "reload",
9+
aliases: [],
10+
11+
async run(message, args, client) {
12+
try {
13+
14+
client.commands.clear();
15+
/**
16+
* @type {Discord.Collection<string, Command>}
17+
*/
18+
this.commands = new Discord.Collection();
19+
this.aliases = new Discord.Collection();
20+
21+
let commands = 0;
22+
fs.readdirSync("./commands")
23+
.filter(file => file.endsWith(".js"))
24+
.forEach(file => {
25+
commands++;
26+
/**
27+
* @type {Command}
28+
*/
29+
const command = require(`../commands/${file}`);
30+
console.log(chalk.greenBright(`[COMMAND] Reloaded ${(chalk.yellow(file))} with command ${(chalk.yellow(command.name))} ${(chalk.yellow(`[${command.aliases}]`))}`));
31+
client.commands.set(command.name, command);
32+
33+
if (command.aliases) {
34+
command.aliases.forEach(alias => {
35+
this.aliases.set(command.alias, command);
36+
});
37+
};
38+
});
39+
console.log(chalk.greenBright(`[COMMAND] Reloaded ${(chalk.yellow(commands))} commands!`));
40+
message.reply(`${commands} commands have been reloaded!`);
41+
42+
} catch (error) {
43+
console.log(error);
44+
}
45+
}
46+
});

commands/setprefix.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ const Command = require("../structures/command.js");
22
const Discord = require("discord.js");
33
const config = require("../data/config.json");
44
const { red } = require('chalk');
5-
const mysql = require('mysql');
5+
const mysql = require('mysql2');
66
const util = require('util');
77

8-
const embeds = require('../utils/embeds.js');
9-
108
var con = mysql.createPool({
119
multipleStatements: true,
1210
insecureAuth: true,
@@ -30,20 +28,19 @@ module.exports = new Command({
3028

3129
let rows = await dbquery(`SELECT * FROM guilds WHERE guildid = '${message.guild.id}'`);
3230

33-
if (!args[1]) return embeds.errorEmbed(client, message, `Use ${rows[0].prefix}setprefix <prefix>`);
31+
if (!args[1]) return message.reply(`Use ${rows[0].prefix}setprefix <prefix>`);
3432

3533
await dbquery(`UPDATE guilds SET prefix = '${args[1]}' WHERE guildid = '${message.guild.id}'`);
3634

37-
const embed = new Discord.MessageEmbed()
35+
const embed = new Discord.EmbedBuilder()
3836
.setTitle("Prefix changed!")
3937
.setDescription(`The prefix has been changed to ${args[1]}`)
4038
.setColor("149C51")
4139

4240
message.reply({embeds: [embed]});
4341

4442
} catch (error) {
45-
embeds.errorEmbed(client, message, "Something went wrong.");
46-
console.log(red(`[COMMAND] In the command ${this.name} an error has occurred -> ${error}`))
43+
console.log(error);
4744
}
4845
}
4946
});

data/config.json.TEMPLATE

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
{
2-
"token": "TOKEN",
2+
"bot": {
3+
"token": "TOKEN",
4+
"intents": "0",
5+
"eval": "0"
6+
},
37
"mysql": {
48
"host": "HOST",
59
"port": PORT,
610
"user": "USER",
711
"password": "PASSWORD",
812
"database": "DATABASE"
9-
},
10-
"eval": "USERID"
13+
}
1114
}

events/messageCreate.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
const Event = require("../structures/event.js");
22
const config = require("../data/config.json");
3-
const { red } = require('chalk');
4-
const mysql = require('mysql');
3+
const mysql = require('mysql2');
54
const util = require('util');
65

7-
const embeds = require('../utils/embeds.js');
8-
96
var con = mysql.createPool({
10-
multipleStatements: true,
11-
insecureAuth: true,
127
host: `${config.mysql.host}`,
138
port: `${config.mysql.port}`,
149
user: `${config.mysql.user}`,
@@ -27,21 +22,20 @@ module.exports = new Event("messageCreate", async(client, message) => {
2722
if (rows.length < 1) await dbquery(`INSERT INTO guilds (id, guildid) VALUES (NULL, '${message.guild.id}')`);
2823

2924
const p = await getprefix(message.guild.id);
30-
const prefix = await p
25+
const prefix = await p;
3126

3227
if (message.content.startsWith(prefix)) {
3328
const args = message.content.substring(prefix.length).split(/ +/);
3429
const command = client.commands.find(cmd => cmd.name == args[0] || cmd.aliases.includes(args[0]));
35-
if (!command) return //message.reply(`${args[0]} is not a valid command!`);
30+
if (!command) return //message.reply(`${args[0]} is not a valid command!`); //uncomment this if you want that the bot replies when the error is not a valid command!
3631
command.run(message, args, client)
3732
} else {
3833
// Here you can add commands that are not have a prefix.
3934
// like when somebody pings the bot.
4035
}
4136

4237
} catch (error) {
43-
embeds.errorEmbed(client, message, "Something went wrong.");
44-
return console.log(red(`[EVENT] In the event messageCreate an error has occurred -> ${error}`))
38+
return console.log(error);
4539
}
4640
});
4741

events/ready.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const Event = require("../structures/event.js");
22
const config = require("../data/config.json");
33
const { red, yellow } = require('chalk');
44
const { version } = require('../package.json');
5-
const mysql = require('mysql');
5+
const mysql = require('mysql2');
66
const util = require('util');
77

88
var con = mysql.createPool({

index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const config = require("./data/config.json");
66

77
process.on('uncaughtException', function (err) {
88
console.error(err);
9-
console.log("Node NOT Exiting...");
109
});
1110

12-
client.start(config.token);
11+
client.start(config.bot.token);

0 commit comments

Comments
 (0)