Files
xiao/commands/textedit/rin.js
T
2017-03-23 13:39:50 +00:00

42 lines
1.4 KiB
JavaScript

const commando = require('discord.js-commando');
const request = require('superagent');
const config = require('../../config.json');
module.exports = class RinSayCommand extends commando.Command {
constructor(Client) {
super(Client, {
name: 'rin',
aliases: [
'rinsay'
],
group: 'textedit',
memberName: 'rin',
description: "Posts a message to the Rin webhook in Heroes of Dreamland. (;rin Hey guys!)",
examples: [";rin Hey guys!"]
});
}
hasPermission(msg) {
return this.client.isOwner(msg.author);
}
async run(message) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log(`[Command] ${message.content}`);
let rinContent = message.content.split(" ").slice(1).join(" ");
return request
.post(config.webhook)
.send({
content: rinContent
})
.then(function(parsedBody) {
if (message.content.type === 'dm') return;
return message.delete();
}).catch(function(err) {
console.log(err);
return message.channel.send(':x: Error! Message failed to send! Check the logs for details.');
});
}
};