Files
xiao/commands/response/fact.js
T
2017-03-03 18:16:21 -05:00

28 lines
913 B
JavaScript

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;