fix wallet name errors/set wallet parameters"

This commit is contained in:
SowinskiBraeden committed 2022-07-10 23:54:36 -07:00
1 parent 3c74864d27
commit 0dd0d7b11e
3 files changed
+101 -5

No files matched your search

+90
View File
@@ -0,0 +1,90 @@
const { MessageEmbed } = require('discord.js');
module.exports = {
name: "id-set",
description: "set a value on your wallet ID",
usage: "[firstname/lastname/dob] [value]",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
SlashCommand: {
options: [
{
name: "change",
description: "what you'd like to change on your ID",
value: "change",
type: 3,
required: true,
choices: [
{ name: "firstname", value: "firstname" }, { name: "lastname", value: "lastname" }, { name: "date-of-birth", value: "dob" },
],
},
{
name: "value",
description: "new value of what you'd like to change",
value: "value",
type: 3,
required: true,
},
],
/**
*
* @param {require("../structures/QuarksBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, interaction, args, { GuildDB }) => {
if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) {
return interaction.send(`You are not allowed to use the bot in this channel.`);
}
const query = {"inventory.userID":interaction.member.user.id, "inventory.items.type":"wallet"};
let update, updateAction;
if (args[0].value == "firstname") {
update = {$set: {"inventory.items.$.ID.firstname": args[1].value}};
updateAction = "firstname";
} else if (args[0].value == "lastname") {
update = {$set: {"inventory.items.$.ID.lastname": args[1].value}};
updateAction = "lastname";
} else if (args[0].value == "dob") {
const isDate = (date) => {
return (new Date(date) !== "Invalid Date") && !isNaN(new Date(date));
}
if (!isDate(args[1].value)) {
let embed = new MessageEmbed()
.setTitle("Invalid Date of Birth")
.setColor("RED");
return interaction.send({ embeds: [embed] });
}
update = {$set: {"inventory.items.$.ID.dob": args[1].value}};
updateAction = "date of birth";
}
client.dbo.collection("inventories").updateOne(query, update, function (err, res) {
if (err) {
client.log(err);
let embed = new MessageEmbed()
.setTitle(err)
.setColor("RED")
return interaction.send({ embeds: [embed] });
}
});
let successEmbed = new MessageEmbed()
.setTitle('Success')
.setDescription(`Successfully set ${updateAction}\nUse \`/inventory wallet\` to view your updated ID`)
.setColor('GREEN');
return interaction.send({ embeds: [successEmbed] });
},
},
}
+10 -4
View File
@@ -146,7 +146,7 @@ module.exports = {
// Display wallet
let item = inventory.items[0];
let walletData = `**Cash:** $${item.cash.toFixed(2)}\n**ID:** ${item.ID.firstname ? client.exists(item.ID.firtname) : 'John'} ${item.ID.lastname ? client.exists(item.ID.lastname) : 'Doe'} | ${item.ID.dob ? client.exists(item.ID.dob) : 'N/A'}`
let walletData = `**Cash:** $${item.cash.toFixed(2)}\n**ID:** ${client.exists(item.ID.firstname) ? item.ID.firstname : '...'} ${client.exists(item.ID.lastname) ? item.ID.lastname : '...'} | ${client.exists(item.ID.dob) ? item.ID.dob : 'N/A'}`
let walletEmbed = new MessageEmbed()
.setTitle(`Your Wallet`)
@@ -170,7 +170,7 @@ module.exports = {
if (item.type == 'wallet') {
// Display wallet
let walletData = `**Cash:** $${item.cash}\n**ID:** ${item.ID.firstname ? client.exists(item.ID.firtname) : 'John'} ${item.ID.lastname ? client.exists(item.ID.lastname) : 'Doe'} | ${item.ID.dob ? client.exists(item.ID.dob) : 'N/A'}`
let walletData = `**Cash:** $${item.cash}\n**ID:** ${client.exists(item.ID.firstname) ? item.ID.firstname : '...'} ${client.exists(item.ID.lastname) ? item.ID.lastname : '...'} | ${client.exists(item.ID.dob) ? item.ID.dob : 'N/A'}`
itemEmbed.setTitle(`Your Wallet`);
itemEmbed.setDescription(walletData);
@@ -207,8 +207,7 @@ module.exports = {
if (args[0].options[0].value == 1) {
let embed = new MessageEmbed()
.setTitle("Invalid")
.setDescription("You're not allowed to drop your wallet")
.setTitle("Cannot Drop Wallet")
.setColor(client.config.EmbedColor);
return interaction.send({ embeds: [embed] });
@@ -245,6 +244,13 @@ module.exports = {
}
let item = inventory.items[args[0].options[0].value-1];
if (item.type == 'wallet') {
let embed = new MessageEmbed()
.setTitle("Cannot Give Wallet")
.setColor("RED");
return interaction.send({ embeds: [embed] });
}
let targetUserID = args[0].options[1].value.replace('<@!', '').replace('>', '');
let targetUserInventory = await client.dbo.collection("inventories").findOne({"inventory.userID":targetUserID}).then(inventory => inventory);
+1 -1
View File
@@ -92,7 +92,7 @@ module.exports = {
if (item.type == 'wallet') {
// Display wallet
let walletData = `**Cash:** $${item.cash}\n**ID:** ${item.ID.firstname ? client.exists(item.ID.firtname) : 'John'} ${item.ID.lastname ? client.exists(item.ID.lastname) : 'Doe'} | ${item.ID.dob ? client.exists(item.ID.dob) : 'N/A'}`
let walletData = `**Cash:** $${item.cash}\n**ID:** ${client.exists(item.ID.firstname) ? item.ID.firstname : '...'} ${client.exists(item.ID.lastname) ? item.ID.lastname : '...'} | ${client.exists(item.ID.dob) ? item.ID.dob : 'N/A'}`
itemEmbed.setTitle(`${User.tag.split('#')[0]}'s Wallet`);
itemEmbed.setDescription(walletData);