if no comment remove the comment

This commit is contained in:
loicbersier 2019-11-13 20:26:43 +01:00
parent 4113b0dab1
commit 52c61d4e89

View file

@ -35,6 +35,8 @@ class addDonatorCommand extends Command {
let userComment = ''; let userComment = '';
if (args.userComment) { if (args.userComment) {
userComment = args.userComment; userComment = args.userComment;
} else if (args.userComment == '') {
userComment = null;
} }
const Donator = await donator.findOne({where: {userID: args.id}}); const Donator = await donator.findOne({where: {userID: args.id}});
@ -51,6 +53,9 @@ class addDonatorCommand extends Command {
if (messageContent == 'y' || messageContent == 'yes') { if (messageContent == 'y' || messageContent == 'yes') {
const body = {comment: userComment}; const body = {comment: userComment};
donator.update(body, {where: {userID: args.id}}); donator.update(body, {where: {userID: args.id}});
if (userComment == null) {
return message.channel.send(`Removed the comment from ${this.client.users.get(args.id).username}#${this.client.users.get(args.id).discriminator} (${args.id})`);
}
return message.channel.send(`You edited the comment for ${this.client.users.get(args.id).username}#${this.client.users.get(args.id).discriminator} (${args.id}) with ${args.userComment}`); return message.channel.send(`You edited the comment for ${this.client.users.get(args.id).username}#${this.client.users.get(args.id).discriminator} (${args.id}) with ${args.userComment}`);
} }
}) })