Chech if these files exists

This commit is contained in:
loicbersier 2019-06-28 17:05:01 +02:00
parent da53c24feb
commit e9f73ab462
3 changed files with 164 additions and 160 deletions

View file

@ -1,5 +1,5 @@
const { Listener } = require('discord-akairo');
const reload = require('auto-reload');
const fs = require('fs');
const rand = require('../../rand.js');
class guildMemberAddListener extends Listener {
@ -11,8 +11,8 @@ class guildMemberAddListener extends Listener {
}
async exec(guild) {
let welcome = reload(`../../welcome/${guild.guild.id}.json`);
if (fs.existsSync(`./welcome/${guild.guild.id}.json`)) {
let welcome = require(`../../welcome/${guild.guild.id}.json`);
const channel = this.client.channels.get(welcome['channel']);
let welcomeMessage = welcome['message'];
@ -42,4 +42,5 @@ class guildMemberAddListener extends Listener {
}
}
}
}
module.exports = guildMemberAddListener;

View file

@ -1,5 +1,5 @@
const { Listener } = require('discord-akairo');
const reload = require('auto-reload');
const fs = require('fs');
const rand = require('../../rand.js');
class guildMemberRemoveListener extends Listener {
@ -11,7 +11,8 @@ class guildMemberRemoveListener extends Listener {
}
async exec(guild) {
let bye = reload(`../../bye/${guild.guild.id}.json`);
if (fs.existsSync(`./bye/${guild.guild.id}.json`)) {
let bye = require(`../../bye/${guild.guild.id}.json`);
const channel = this.client.channels.get(bye['channel']);
@ -42,4 +43,5 @@ class guildMemberRemoveListener extends Listener {
}
}
}
}
module.exports = guildMemberRemoveListener;

View file

@ -5,6 +5,7 @@ const reactObject = require('../../json/react.json');
const imgResponseObject = require('../../json/imgreply.json');
const rand = require('../../rand.js');
const reload = require('auto-reload');
const fs = require('fs');
class messageListener extends Listener {
constructor() {
@ -41,12 +42,9 @@ class messageListener extends Listener {
}
}
// User autoresponse
let customresponse;
try {
customresponse = reload(`../../tag/${message.guild.id}.json`);
} catch (err) {
null;
}
if (fs.existsSync(`./tag/${message.guild.id}.json`)) {
let customresponse = require(`../../tag/${message.guild.id}.json`);
try {
if(customresponse[message_content]) {
@ -180,6 +178,9 @@ class messageListener extends Listener {
} catch (err) {
null;
}
}
}
}