Rin Say and Servers in Seperate Files

This commit is contained in:
dragonfire535
2017-03-16 18:22:52 -04:00
parent bad59576f0
commit 1a21a88ade
3 changed files with 75 additions and 28 deletions
+43
View File
@@ -0,0 +1,43 @@
const commando = require('discord.js-commando');
const request = require('request-promise');
const config = require('../../config.json');
class RinSayCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'rin',
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, 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);
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;
message.delete();
}).catch(function (err) {
console.log(err);
});
}
}
module.exports = RinSayCommand;
+28
View File
@@ -0,0 +1,28 @@
const commando = require('discord.js-commando');
class ServersCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'servers',
group: 'util',
memberName: 'servers',
description: "Sends a list of all server names and IDs to the log.",
examples: [";servers"]
});
}
hasPermission(msg) {
return this.client.isOwner(msg.author);
}
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);
console.log(this.client.guilds.array().length + " Servers: " + this.client.guilds.map(g => g.name + " (" + g.id + ")").join(", "));
message.channel.send("Sent the information to the console!");
}
}
module.exports = ServersCommand;
+4 -28
View File
@@ -37,41 +37,17 @@ client.registry
client.on('message', (message) => {
if(message.author.bot) return;
if(message.content.startsWith(';servers')) {
if(message.author.id !== config.owner) return;
console.log("[Command] " + message.content);
console.log(client.guilds.array().length + " Servers: " + client.guilds.map(g => g.name + " (" + g.id + ")").join(", "));
message.channel.send("Sent the information to the console!");
}
if(message.content.includes("(╯°□°)╯︵ ┻━┻")) {
if(message.channel.type !== 'dm') {
if(message.guild.id === "110373943822540800") return;
}
if(message.channel.type === 'dm') return;
if(message.guild.id === "110373943822540800") return;
console.log("[Command] " + message.content);
message.channel.send("Calm down! ┬─┬ ( ゜-゜ノ)");
}
if(message.content.includes(":Swagolor:")) {
if(message.channel.type === 'dm') return;
if(message.guild.id !== config.server) return;
message.channel.send(message.guild.emojis.get('254827709459333120').toString());
}
if (message.content.startsWith(';rinsay')) {
if (message.author.id !== config.owner) return;
let messagecontent = message.content.split(" ").slice(1).join(" ");
message.delete();
const sendPOST = {
method: 'POST',
uri: config.webhook,
body: {
content: messagecontent
},
json: true
}
request(sendPOST).then(function (parsedBody) {
console.log('[Rin] ' + messagecontent);
}).catch(function (err) {
console.log(err);
});
}
if(message.channel.type !== 'dm') {
if (message.content.startsWith("<@" + client.user.id + ">")){
if(message.guild.id === config.server || message.author.id === config.owner) {
@@ -188,7 +164,7 @@ client.once('ready', () => {
});
process.on('unhandledRejection', function(reason, p){
console.log("A Possibly Unhandled Rejection has Occurred.");
console.log("A Possibly Unhandled Rejection has Occurred. " + reason);
});
client.login(config.token);