Skip to content

Commit

Permalink
Added checks on JSONs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayfri committed Oct 24, 2020
1 parent c867ef4 commit 0983abd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/classes/SanctionCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module.exports = class SanctionCommand extends Command {
case: this.userData.sanctionsLastNumber,
});
this.userData.sanctionsLastNumber++;
if (!writeInJSON('./assets/jsons/userData.json', this.userData)) {
if (!writeInJSON('./assets/jsons/userdata.json', this.userData)) {
return runError(this.message, this, `Tentative d'écriture dans le fichier './assets/jsons/userdata.json', le fichier n'a pas été trouvé.`);
}

Expand Down
7 changes: 6 additions & 1 deletion src/commands/moderation/infractions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const {MessageEmbed} = require('discord.js');
const Command = require('../../entities/Command.js');
const {runError} = require('../../utils/Errors.js');
const {readJSON} = require('../../utils/Utils.js');
const {argTypes, tags} = require('../../constants.js');
const {getArg, getArgWithContent} = require('../../utils/ArgUtils.js');
Expand Down Expand Up @@ -63,7 +64,7 @@ module.exports = class InfractionsCommand extends Command {
userData[message.guild.id][person.user.id] = {
sanctions: [],
};
writeInJSON('./assets/jsons/userdata.json', userData);
this.writeData(userData);
}

if (args[1] === 'supprimer') {
Expand Down Expand Up @@ -111,4 +112,8 @@ module.exports = class InfractionsCommand extends Command {

return this.createPage(userData, page, person.user, embed);
}

writeData(userData) {
if (!writeInJSON('./assets/jsons/userdata.json', userData)) runError(this.message, this, "Tentative d'écriture dans le fichier './assets/jsons/userdata.json', le fichier n'a pas été trouvé.");
}
};
4 changes: 1 addition & 3 deletions src/events/ready.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ module.exports = class ReadyEvent extends Event {

async run(client) {
await super.run(client);
// Status

this.setRandomPresence();
setInterval(() => this.setRandomPresence(), 10 * 1000);

// REBOOT
const config = readJSON('./assets/jsons/config.json');
if (config.statut === 'reboot') {
if (client.channels.cache.has(config.cacheChannel)) client.channels.cache.get(config.cacheChannel).send('Relancement du bot fini.');
Expand All @@ -52,7 +51,6 @@ module.exports = class ReadyEvent extends Event {
config.dateUpdate = parseDate('dd/MM/yyyy');
writeInJSON('./assets/jsons/config.json', config);

// Logging
Logger.info(`${client.user.username} (${client.user.id}) Est allumé ! Nombre de serveurs : ${client.guilds.cache.size}.`, 'ReadyEvent');

this.logInfosOfBot();
Expand Down

0 comments on commit 0983abd

Please sign in to comment.