Fact Command Added

This commit is contained in:
dragonfire535
2017-03-03 18:16:21 -05:00
parent 8a2232294a
commit 3ff7b9fd14
3 changed files with 30 additions and 1 deletions
+28
View File
@@ -0,0 +1,28 @@
const commando = require('discord.js-commando');
const WikiFakt = require('wikifakt');
class FactCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'fact',
group: 'response',
memberName: 'fact',
description: 'Gets a random fact. (;fact)',
examples: [';fact']
});
}
async run(message, args) {
if(message.channel.type !== 'dm') {
if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return;
}
console.log("[Command] " + message.content);
WikiFakt.preload = false;
WikiFakt.getRandomFact().then(function(fact) {
message.channel.sendMessage(fact);
});
}
}
module.exports = FactCommand;