From ec6ca48ff990f7b29d4541fb3d2d09b34069eb98 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Wed, 23 Feb 2022 22:07:23 -0700 Subject: [PATCH] marriage declining --- commands/fun/marry.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/commands/fun/marry.js b/commands/fun/marry.js index f4a4218..a225082 100644 --- a/commands/fun/marry.js +++ b/commands/fun/marry.js @@ -2,6 +2,8 @@ const Discord = require('discord.js'); const UserData = require('../../models/user'); +const ask = require("../../util/ask"); + module.exports = { name: "marry", meta: { @@ -28,7 +30,33 @@ module.exports = { .setTimestamp() ]});} } else if (['d', 'decline', 'r', 'reject'].includes(args[0].toLowerCase())) { - + let requests = client.misc.cache.marriageRequests.filter(u => u === message.author.id); + if (!requests.size) {return message.channel.send("You don't have any people trying to marry you!");} + let ra = Array.from(requests.keys()); + message.channel.send({embeds: [new Discord.MessageEmbed() + .setTitle("Current Marriage Requests") + .setDescription(ra.map((r, i) => `${i+1}. <@${r}>`).join("\n")) + .addField("Decline", "To decline someone's request, please reply with the number that corresponds to the person you'd like to decline.") + .setColor('c375f0') + .setFooter({text: "Natsuki", iconURL: client.user.avatarURL()}) + .setTimestamp() + ]}); + try { + let res = await message.channel.awaitMessages({filter: (m) => m.author.id === message.author.id, max: 1, errors: ['time'], time: 60000}); + res = res.first().content; + if (isNaN(Number(res))) {return message.channel.send("You must reply with a number!");} + res = Number(res); + if (res < 1 || res > ra.length + 1) {return message.channel.send("That number isn't in your list.");} + let person = ra[res-1]; + let err = false; + await message.guild.members.fetch(person).catch(() => err = true); + if (err) {return message.channel.send("There was an error in trying to do that!");} + let conf = await ask(message, `Are you sure you want to decline ${client.utils.ps(message.guild.members.cache.get(person).displayName)} marriage request?`, 60000); + if (!conf) {return;} + if (!['y', 'yes', 'ye', 'sure', 'mhm'].includes(conf.toLowerCase())) {return message.channel.send("Okay, nevermind then!");} + client.misc.cache.marriageRequests.delete(person); + return message.channel.send("Request declined."); + } catch {return message.reply("That request timed out. Please try again.");} } else { if (!mention) {return message.channel.send("You have to mention the person you'd like to marry!");} if (!message.guild.members.cache.has(mention.id)) {return message.channel.send("I can't find that user! Make sure they're in this server before trying to marry them, or go to a server they're in. If you're certain that person is in this server, then wait for them to come online and send a message first; that might help.");}