mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-20 05:51:35 +02:00
Huge Modification to Code
This commit is contained in:
+16
-19
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user