Proper await

This commit is contained in:
Daniel Odendahl Jr
2017-03-24 02:29:31 +00:00
parent 5329d08581
commit 122fcf5de3
103 changed files with 613 additions and 577 deletions
+14 -13
View File
@@ -21,21 +21,22 @@ module.exports = class RinSayCommand extends commando.Command {
async run(message) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'MANAGE_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.');
});
try {
let post = await request
.post(config.webhook)
.send({
content: rinContent
});
if (message.content.type !== 'dm') {
message.delete();
}
}
catch (err) {
message.channel.send(':x: Error! Message failed to send!');
}
}
};