forked from Supositware/Haha-Yes
handle error
This commit is contained in:
parent
d63be4b80d
commit
005cd1c46d
1 changed files with 27 additions and 18 deletions
|
@ -17,23 +17,32 @@ module.exports = class taglistCommand extends Command {
|
||||||
if(blacklist[message.author.id])
|
if(blacklist[message.author.id])
|
||||||
return message.channel.send("You are blacklisted")
|
return message.channel.send("You are blacklisted")
|
||||||
|
|
||||||
let customresponse = new SelfReloadJSON(`./tag/${message.guild.id}.json`);
|
try {
|
||||||
let count = Object.keys(customresponse).length
|
let customresponse = new SelfReloadJSON(`./tag/${message.guild.id}.json`);
|
||||||
|
let count = Object.keys(customresponse).length
|
||||||
fs.readFile(`./tag/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data){
|
|
||||||
if (err)
|
|
||||||
console.log(err);
|
fs.readFile(`./tag/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data){
|
||||||
let json = JSON.stringify(data)
|
if (err) {
|
||||||
json = json.replace(/[{}"\\]+/g, '')
|
console.log(err);
|
||||||
json = json.replace(/,+/g, '\n')
|
}
|
||||||
const tagEmbed = new Discord.RichEmbed()
|
let json = JSON.stringify(data)
|
||||||
.setColor("#ff9900")
|
json = json.replace(/[{}"\\]+/g, '')
|
||||||
.setTitle('Tags list')
|
json = json.replace(/,+/g, '\n')
|
||||||
.setDescription(`Trigger:Response\n\n${json}`)
|
const tagEmbed = new Discord.RichEmbed()
|
||||||
.setFooter(`You have ${count} tags on this server`)
|
.setColor("#ff9900")
|
||||||
|
.setTitle('Tags list')
|
||||||
message.say(tagEmbed);
|
.setDescription(`Trigger:Response\n\n${json}`)
|
||||||
|
.setFooter(`You have ${count} tags on this server`)
|
||||||
});
|
|
||||||
|
message.say(tagEmbed);
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
message.say('An error has occured, do you have any tags on the server?')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
Loading…
Reference in a new issue