use await

This commit is contained in:
loicbersier 2019-07-17 01:17:03 +02:00
parent 5676ab1128
commit 07ceb10ed6

View file

@ -38,17 +38,17 @@ class TagCommand extends Command {
if (!tag) {
const body = {trigger: args.trigger, response: args.response, ownerID: message.author.id, serverID: message.guild.id};
Tag.create(body);
await Tag.create(body);
return message.channel.send(`tag have been set to ${args.trigger} : ${args.response}`);
} else {
message.channel.send('This tag already exist, do you want to update it? y/n');
const filter = m => m.content && m.author.id == message.author.id;
message.channel.awaitMessages(filter, {time: 5000, max: 1, errors: ['time'] })
.then(messages => {
.then(async messages => {
let messageContent = messages.map(messages => messages.content);
if (messageContent == 'y' || messageContent == 'yes') {
const body = {trigger: args.trigger, response: args.response, ownerID: message.author.id, serverID: message.guild.id};
Tag.update(body, {where: {trigger: args.trigger, serverID: message.guild.id}});
await Tag.update(body, {where: {trigger: args.trigger, serverID: message.guild.id}});
return message.channel.send(`tag have been set to ${args.trigger} : ${args.response}`);
}
})