improved UI/UX for giving items
This commit is contained in:
2 files changed
+64
-25
No files matched your search
+63
-25
@@ -109,13 +109,6 @@ module.exports = {
|
|||||||
value: "give",
|
value: "give",
|
||||||
type: 1,
|
type: 1,
|
||||||
options: [
|
options: [
|
||||||
{
|
|
||||||
name: "item-number",
|
|
||||||
description: "Item to interact with",
|
|
||||||
value: 1,
|
|
||||||
type: 4,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "user",
|
name: "user",
|
||||||
description: "User to give item",
|
description: "User to give item",
|
||||||
@@ -415,24 +408,55 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
} else if (args[0].name == 'give') {
|
} else if (args[0].name == 'give') {
|
||||||
// Give user Item from inventory
|
if (inventory.guilds[GuildDB.serverID].items.length == 1) {
|
||||||
|
const nsi = new EmbedBuilder()
|
||||||
|
.setDescription('**Notice:** No items to give')
|
||||||
|
.setColor(client.config.Colors.Yellow);
|
||||||
|
|
||||||
if (args[0].options[0].value < 1 || args[0].options[0].value > inventory.guilds[GuildDB.serverID].items.length) {
|
return interaction.send({ embeds: [nsi] });
|
||||||
let embed = new EmbedBuilder()
|
|
||||||
.setTitle("Please provide a valid item number")
|
|
||||||
.setColor(client.config.Colors.Red)
|
|
||||||
|
|
||||||
return interaction.send({ embeds: [embed] });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let item = inventory.guilds[GuildDB.serverID].items[args[0].options[0].value-1];
|
let items = new SelectMenuBuilder()
|
||||||
if (item.type == 'wallet') {
|
.setCustomId(`inventorySelect-${interaction.member.user.id}`)
|
||||||
let embed = new EmbedBuilder()
|
.setPlaceholder('Select Item to view')
|
||||||
.setTitle("Cannot Give Wallet")
|
.addOptions(
|
||||||
.setColor(client.config.Colors.Red);
|
{
|
||||||
|
label: 'View All',
|
||||||
return interaction.send({ embeds: [embed] });
|
description: 'View a list of all your inventory items',
|
||||||
|
value: 'all',
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
for (let i = 1; i < inventory.guilds[GuildDB.serverID].items.length; i++) {
|
||||||
|
if (inventory.guilds[GuildDB.serverID].items[i].type == 'firearm') {
|
||||||
|
items.addOptions({
|
||||||
|
label: inventory.guilds[GuildDB.serverID].items[i].weaponType,
|
||||||
|
description: 'View this items description',
|
||||||
|
value: `${i}`
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
items.addOptions({
|
||||||
|
label: inventory.guilds[GuildDB.serverID].items[i].name,
|
||||||
|
description: 'View this items description',
|
||||||
|
value: `${i}`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const opt = new ActionRowBuilder().addComponents(items);
|
||||||
|
|
||||||
|
interaction.send({ components: [opt], flags: (1 << 6) })
|
||||||
|
|
||||||
|
client.once("interactionCreate", async MenuInteraction => {
|
||||||
|
if(!MenuInteraction.isSelectMenu()) return;
|
||||||
|
if (!MenuInteraction.customId.endsWith(MenuInteraction.member.user.id)) {
|
||||||
|
return MenuInteraction.reply({
|
||||||
|
content: "This button is not for you",
|
||||||
|
flags: (1 << 6)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
let item = inventory.guilds[GuildDB.serverID].items[MenuInteraction.values[0]];
|
||||||
let targetUserID = args[0].options[1].value.replace('<@!', '').replace('>', '');
|
let targetUserID = args[0].options[1].value.replace('<@!', '').replace('>', '');
|
||||||
let targetUserInventory = await client.dbo.collection("inventories").findOne({"inventory.userID":targetUserID}).then(inventory => inventory);
|
let targetUserInventory = await client.dbo.collection("inventories").findOne({"inventory.userID":targetUserID}).then(inventory => inventory);
|
||||||
|
|
||||||
@@ -449,10 +473,22 @@ module.exports = {
|
|||||||
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
||||||
.setColor(client.config.Colors.Red)
|
.setColor(client.config.Colors.Red)
|
||||||
|
|
||||||
return interaction.send({ embeds: [embed] });
|
return MenuInteraction.update({ embeds: [embed], components: [] });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
if (!client.exists(targetUserInventory.guilds[GuildDB.serverID])) {
|
||||||
|
const success = addInventory(inventory.guilds, GuildDB.serverID, targetUserID, client);
|
||||||
|
if (!success) {
|
||||||
|
client.log(err);
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
||||||
|
.setColor(client.config.Colors.Red)
|
||||||
|
|
||||||
|
return MenuInteraction.update({ embeds: [embed], components: [] });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
client.dbo.collection('inventories').updateOne({'inventory.userID': interaction.member.user.id}, {$pull: {[`inventory.guilds.${GuildDB.serverID}.items`]: item}}, function(err, res) {
|
client.dbo.collection('inventories').updateOne({'inventory.userID': interaction.member.user.id}, {$pull: {[`inventory.guilds.${GuildDB.serverID}.items`]: item}}, function(err, res) {
|
||||||
if (err) {
|
if (err) {
|
||||||
client.log(err);
|
client.log(err);
|
||||||
@@ -460,7 +496,7 @@ module.exports = {
|
|||||||
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
||||||
.setColor(client.config.Colors.Red)
|
.setColor(client.config.Colors.Red)
|
||||||
|
|
||||||
return interaction.send({ embeds: [embed] });
|
return MenuInteraction.update({ embeds: [embed], components: [] });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
client.dbo.collection('inventories').updateOne({'inventory.userID': targetUserID}, {$push: {[`inventory.guilds.${GuildDB.serverID}.items`]: item}}, function(err, res) {
|
client.dbo.collection('inventories').updateOne({'inventory.userID': targetUserID}, {$push: {[`inventory.guilds.${GuildDB.serverID}.items`]: item}}, function(err, res) {
|
||||||
@@ -470,7 +506,7 @@ module.exports = {
|
|||||||
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
||||||
.setColor(client.config.Colors.Red)
|
.setColor(client.config.Colors.Red)
|
||||||
|
|
||||||
return interaction.send({ embeds: [embed] });
|
return MenuInteraction.update({ embeds: [embed], components: [] });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -480,7 +516,9 @@ module.exports = {
|
|||||||
.setDescription(`Successfully gave <@${targetUserID}> ${item.name}`)
|
.setDescription(`Successfully gave <@${targetUserID}> ${item.name}`)
|
||||||
.setColor('GREEN');
|
.setColor('GREEN');
|
||||||
|
|
||||||
return interaction.send({ embeds: [successEmbed] });
|
return MenuInteraction.update({ embeds: [successEmbed], components: [] });
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
|
||||||
} else if (args[0].name == 'clear') {
|
} else if (args[0].name == 'clear') {
|
||||||
const prompt = new EmbedBuilder()
|
const prompt = new EmbedBuilder()
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ module.exports = {
|
|||||||
Default: "#6e5145",
|
Default: "#6e5145",
|
||||||
Red: "#ba0f0f",
|
Red: "#ba0f0f",
|
||||||
Green: "#32a852",
|
Green: "#32a852",
|
||||||
|
Yellow: "#ffb01f"
|
||||||
},
|
},
|
||||||
Permissions: 2205281600,
|
Permissions: 2205281600,
|
||||||
mongoURI: process.env.mongoURI || "mongodb://localhost:27017",
|
mongoURI: process.env.mongoURI || "mongodb://localhost:27017",
|
||||||
|
|||||||
Reference in new issue
Block a user