mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-27 06:37:32 +02:00
Proper await
This commit is contained in:
+14
-13
@@ -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!');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user