Huge Modification to Code

This commit is contained in:
Daniel Odendahl Jr
2017-03-21 19:20:47 +00:00
parent 65bf037068
commit d49fe32bf6
100 changed files with 1541 additions and 2049 deletions
+16 -19
View File
@@ -1,11 +1,14 @@
const commando = require('discord.js-commando');
const request = require('request-promise');
const request = require('superagent');
const config = require('../../config.json');
class RinSayCommand extends commando.Command {
module.exports = class RinSayCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'rin',
name: 'rin',
aliases: [
'rinsay'
],
group: 'textedit',
memberName: 'rin',
description: "Posts a message to the Rin webhook in Heroes of Dreamland. (;rin Hey guys!)",
@@ -16,28 +19,22 @@ class RinSayCommand extends commando.Command {
return this.client.isOwner(msg.author);
}
async run(message, args) {
async run(message) {
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;
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(" ");
const sendPOST = {
method: 'POST',
uri: config.webhook,
body: {
content: rinContent
},
json: true
}
request(sendPOST).then(function (parsedBody) {
if(message.channel.type === 'dm') return;
request
.post(config.webhook)
.send({ content: rinContent })
.then(function (parsedBody) {
message.channel.send('Message sent to the Rin Webhook!');
if(message.content.type === 'dm') return;
message.delete();
}).catch(function (err) {
message.channel.send(':x: Error! Message failed to send! Check the logs for details.');
console.log(err);
});
}
}
module.exports = RinSayCommand;
};