From 3f02eb70d09320285df6675a9fc3ecdb2c55ec8f Mon Sep 17 00:00:00 2001 From: Neko Life Date: Thu, 27 May 2021 22:51:25 +0000 Subject: [PATCH] use: setOnInsert --- cmds/utility/quoteotd.js | 6 +++--- cmds/utility/setfootq.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmds/utility/quoteotd.js b/cmds/utility/quoteotd.js index d693518..a021420 100644 --- a/cmds/utility/quoteotd.js +++ b/cmds/utility/quoteotd.js @@ -36,13 +36,13 @@ module.exports = class quoteotd extends commando.Command { if (!this.client.channels.cache.get(data)) { return trySend(this.client, msg, 'Invalid/unknown channel provided! Try mentioning a channel or use `ChannelID`'); } else { - col.updateOne({document: msg.guild.id}, {$set: {"settings.quoteOTD.channel": data}}, { upsert: true }); + col.updateOne({document: msg.guild.id}, {$set: {"settings.quoteOTD.channel": data}, $setOnInsert: { document: msg.guild.id }}, { upsert: true }); result = result+`Channel set to \`${this.client.channels.cache.get(data).name}\`\n`; } } if (startW.startsWith('text')) { data = arr.slice('text'.length).trim(); - col.updateOne({document: msg.guild.id}, {$set: {"settings.quoteOTD.footerText": data}}, { upsert: true }); + col.updateOne({document: msg.guild.id}, {$set: {"settings.quoteOTD.footerText": data}, $setOnInsert: { document: msg.guild.id }}, { upsert: true }); result = result+`Footer text set to \`${data}\`\n`; } if (startW.startsWith('icon')) { @@ -50,7 +50,7 @@ module.exports = class quoteotd extends commando.Command { if (!/^http/.test(data)) { return trySend(this.client, msg, 'Invalid icon url provided!'); } else { - col.updateOne({document: msg.guild.id}, {$set: {"settings.quoteOTD.footerIcon": data}}, { upsert: true }); + col.updateOne({document: msg.guild.id}, {$set: {"settings.quoteOTD.footerIcon": data}, $setOnInsert: { document: msg.guild.id }}, { upsert: true }); result = result+`Footer icon set!\n`; } } diff --git a/cmds/utility/setfootq.js b/cmds/utility/setfootq.js index f9ce8f6..e427c40 100644 --- a/cmds/utility/setfootq.js +++ b/cmds/utility/setfootq.js @@ -17,14 +17,14 @@ module.exports = class setfootq extends commando.Command { } async run(msg, args) { try { - if (!msg.guild?.member(msg.author).hasPermission("MANAGE_GUILD" && !this.client.owners.includes(msg.author))) { + if (msg.guild ? !msg.guild.member(msg.author).hasPermission("MANAGE_GUILD") : false && !this.client.owners.includes(msg.author.id)) { return trySend(this.client, msg, 'No lol'); } const data = msg.guild ? "Guild" : "User"; const col = database.collection(data); const doc = msg.guild?.id ?? msg.author.id; const oldQ = await col.findOne({document: doc}); - col.updateOne({document: doc}, {$set: {"settings.defaultEmbed.footerQuote": args.trim()}}, { upsert: true }, async (e) => { + col.updateOne({document: doc}, {$set: {"settings.defaultEmbed.footerQuote": args.trim()}, $setOnInsert: { document: msg.guild?.id ?? msg.author.id }}, { upsert: true }, async (e) => { if (e) { return errLog(e, msg, this.client); }