diff --git a/mongo/models/idDarSchema.js b/mongo/models/idDarSchema.js index 5b07d50..3d6db28 100644 --- a/mongo/models/idDarSchema.js +++ b/mongo/models/idDarSchema.js @@ -22,6 +22,10 @@ const idDarSchema = new mongoose.Schema({ type: [radarEntrySchema], default: [], }, + lesdar: { + type: [radarEntrySchema], + default: [], + }, bidar: { type: [radarEntrySchema], default: [], diff --git a/src/bot.js b/src/bot.js index 8195f8b..698238a 100644 --- a/src/bot.js +++ b/src/bot.js @@ -35,6 +35,7 @@ const userprofile = require("./commands/Profile/userprofile.js"); const usergaydar = require("./commands/Fun/usergaydar.js"); const usertransdar = require("./commands/Fun/usertransdar.js"); const userqueerdar = require("./commands/Fun/userqueerdar.js"); +const userlesdar = require("./commands/Fun/userlesdar.js"); const useravatar = require("./commands/Avatar/useravatar-view.js"); module.exports = (client) => { @@ -246,6 +247,7 @@ module.exports = (client) => { const handlers = { "User Profile": userprofile, "User Gaydar": usergaydar, + "User Lesdar": userlesdar, "User Transdar": usertransdar, "User Queerdar": userqueerdar, "User Avatar-view": useravatar, diff --git a/src/commands/fun/lesdar.js b/src/commands/fun/lesdar.js new file mode 100644 index 0000000..ad2d710 --- /dev/null +++ b/src/commands/fun/lesdar.js @@ -0,0 +1,90 @@ +const { SlashCommandBuilder, EmbedBuilder } = require("discord.js"); +const commandLogging = require("../../config/logging/commandlog"); +const darlogging = require("../../config/logging/darlog"); +const DarList = require("../../../mongo/models/idDarSchema"); + +const utility_functions = { + chance: function (probability) { + return Math.random() <= probability; + }, + number_format_commas: function (number) { + return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); + }, +}; + +module.exports = { + data: new SlashCommandBuilder() + .setName("lesdar") + .setDescription("How lesbian are you?") + .addUserOption((option) => + option + .setName("target") + .setDescription("See how lesbian a user is") + .setRequired(false) + ), + + async execute(interaction, client) { + await interaction.deferReply(); + + const targetUser = + interaction.options.getUser("target") || interaction.user; + const userName = targetUser.username; + const userid = targetUser.id; + + let meter; + try { + const darList = await DarList.findOne(); + + if (darList) { + const lesdarEntry = darList.lesdar.find( + (entry) => entry.userid === userid + ); + + if (lesdarEntry) { + meter = lesdarEntry.meter; + } else { + meter = Math.floor(Math.random() * 101); + if (utility_functions.chance(0.0001)) { + meter = Math.floor(Math.random() * 2354082) + 500; + if (utility_functions.chance(0.5)) { + meter *= -1; + } + } + } + } else { + meter = Math.floor(Math.random() * 101); + + if (utility_functions.chance(0.0001)) { + meter = Math.floor(Math.random() * 2354082) + 500; + if (utility_functions.chance(0.5)) { + meter *= -1; + } + } + } + } catch (err) { + console.error(err); + meter = Math.floor(Math.random() * 101); + } + + const embed = new EmbedBuilder() + .setTitle(`How lesbian is ${userName}?`) + .setDescription( + `<@${userid}> is **${userid === "1201827969585393676" ? "1000000000000000000000000" : utility_functions.number_format_commas( + meter + )}% lesbian!**` + ) + .setColor(0xff00ae) + .setFooter({ + text: "The bot has 99.99% accuracy rate on checking users lesbianness", + }); + + try { + await interaction.editReply({ embeds: [embed] }); // Edit the deferred reply + } catch (error) { + console.error("Error sending response:", error); + } + + await commandLogging(client, interaction); + await darlogging(client, "Lesdar", userName, meter, userid); + }, +}; diff --git a/src/commands/fun/userlesdar.js b/src/commands/fun/userlesdar.js new file mode 100644 index 0000000..74c3c67 --- /dev/null +++ b/src/commands/fun/userlesdar.js @@ -0,0 +1,77 @@ +const { + EmbedBuilder, + ContextMenuCommandBuilder, + ApplicationCommandType, +} = require("discord.js"); +const DarList = require("../../../mongo/models/idDarSchema"); +const darlogging = require("../../config/logging/darlog"); + +const utility_functions = { + chance: function (probability) { + return Math.random() <= probability; + }, + number_format_commas: function (number) { + return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); + }, +}; + +module.exports = { + data: new ContextMenuCommandBuilder() + .setName("User Lesdar") + .setType(ApplicationCommandType.User), + + async execute(interaction, client) { + const targetUser = interaction.targetUser; + const userName = targetUser.username; + const userid = targetUser.id; + + let meter; + try { + const darList = await DarList.findOne(); + + if (darList) { + const gaydarEntry = darList.lesdar.find( + (entry) => entry.userid === userid + ); + + if (gaydarEntry) { + meter = gaydarEntry.meter; + } else { + meter = Math.floor(Math.random() * 101); + if (utility_functions.chance(0.0001)) { + meter = Math.floor(Math.random() * 2354082) + 500; + if (utility_functions.chance(0.5)) { + meter *= -1; + } + } + } + } else { + meter = Math.floor(Math.random() * 101); + if (utility_functions.chance(0.0001)) { + meter = Math.floor(Math.random() * 2354082) + 500; + if (utility_functions.chance(0.5)) { + meter *= -1; + } + } + } + } catch (err) { + console.error(err); + meter = Math.floor(Math.random() * 101); + } + + const embed = new EmbedBuilder() + .setTitle(`How lesbian is ${userName}?`) + .setDescription( + `<@${userid}> is **${utility_functions.number_format_commas( + meter + )}% lesbian!**` + ) + .setColor(0xff00ae) + .setFooter({ + text: "The bot has 99.99% accuracy rate on checking users lesbianness", + }); + + await interaction.reply({ embeds: [embed] }); + await darlogging(client, "User Gaydar", userName, meter, userid); + }, +};