From a5e62cceb17ac6dadb3d760c6b53df8d5a094840 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Fri, 28 Jan 2022 12:24:33 -0700 Subject: [PATCH] accept submitted characters --- commands/anime/char.js | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/commands/anime/char.js b/commands/anime/char.js index 7103276..52ad34a 100644 --- a/commands/anime/char.js +++ b/commands/anime/char.js @@ -367,7 +367,7 @@ module.exports = { if (['reject'].includes(args[0].trim().toLowerCase())) { let tu = await UserData.findOne({uid: message.author.id}); if (!tu || !tu.staff) {await message.channel.send("Since you aren't a Natsuki Staff member, you can't reject character submissions!");} - let tr = await CharData.findOne({id: args[1].toLowerCase()}); + let tr = await Char.findOne({id: args[1].toLowerCase()}); if (!tr) {return message.reply("That character submission doesn't seem to exist!");} if (tr.queued !== true) {return message.reply("That character was already accepted, so you can't reject it.");} return await CharData.deleteOne({id: args[1].toLowerCase()}) @@ -375,6 +375,33 @@ module.exports = { .catch(() => {return message.reply("It seems that submission wasn't deleted for some reason. \*insert head scratching*");}); } + if (['accept', 'approve'].includes(args[0].toLowerCase())) { + let tu = await UserData.findOne({uid: message.author.id}); + if (!tu || !tu.staff) {await message.channel.send("Since you aren't a Natsuki Staff member, you can't accept character submissions!");} + let tr = await Char.findOne({id: args[1].toLowerCase()}); + if (!tr) {return message.reply("That character submission doesn't seem to exist!");} + if (tr.queued !== true) {return message.reply("That character was already accepted, so you can't accept it again...");} + tr.queued = false; + return await tr.save() + .then(() => { + client.misc.cache.chars.set(tr.name.normalize("NFD").replace(/[\u0300-\u036f]/g, ""), tr.id); + tr.nicknames.forEach(nn => client.misc.cache.chars.set(nn.normalize("NFD").replace(/[\u0300-\u036f]/g, ""), tr.id)); + client.misc.cache.charsID.set(tr.id, tr.name.normalize("NFD").replace(/[\u0300-\u036f]/g, "")); + client.misc.cache.charsNum++; + client.guilds.cache.get('762707532417335296').channels.cache.get('932177797705781308').send({embeds: [new Discord.MessageEmbed() + .setTitle(`Character Accepted -> ${tr.name}`) + .setAuthor({name: 'Character Approved', iconURL: message.author.avatarURL()}) + .setThumbnail(tr.thumbnail) + .setDescription(`${tr.name} has been approved, and is now available to all Natsuki users.`) + .setColor('c375f0') + .setFooter({text: "Natsuki"}) + .setTimestamp() + ]}).catch(() => {}); + return message.channel.send("I've accepted that submission."); + }) + .catch(() => {return message.reply("It seems that submission wasn't accepted for some reason. \*insert head scratching*");}); + } + if (['r', 'rand', 'random', 'any'].includes(args[0].toLowerCase())) { let asr = await chs(message, client, client.misc.cache.chars.random(), -100000); return await message.channel.send({embeds: [asr.embed]});