Merge master into dev-new-rendering #58
@@ -13,7 +13,7 @@ module.exports = {
|
|||||||
.setDescription("View missing things")
|
.setDescription("View missing things")
|
||||||
.addStringOption((option) =>
|
.addStringOption((option) =>
|
||||||
option
|
option
|
||||||
.setName("group_id")
|
.setName("group")
|
||||||
.setDescription("Thing identifier")
|
.setDescription("Thing identifier")
|
||||||
.setRequired(false)
|
.setRequired(false)
|
||||||
.setAutocomplete(true)
|
.setAutocomplete(true)
|
||||||
@@ -22,22 +22,36 @@ module.exports = {
|
|||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
|
||||||
let groupId = interaction.options.getString("group_id");
|
let groupId = interaction.options.getString("group");
|
||||||
let user = await UserUtils.getUserByDiscordId(interaction.member.user.id);
|
let user = await UserUtils.getUserByDiscordId(interaction.member.user.id);
|
||||||
|
|
||||||
|
let embed = new EmbedBuilder()
|
||||||
|
.setTitle(`Missing cards`);
|
||||||
|
let description = "";
|
||||||
|
|
||||||
if (groupId) {
|
if (groupId) {
|
||||||
try {
|
try {
|
||||||
let missingCards = await this.FindMissingFromGroup(user.id, groupId);
|
let missing = await this.FindMissingFromGroup(user.id, groupId);
|
||||||
await interaction.editReply(JSON.stringify(missingCards));
|
missing.map((character) => {
|
||||||
return;
|
description += `[${character.id}] ${character.name}\n`;
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
let missingCounts = await this.CountMissingFromGroup(user.id);
|
||||||
|
missingCounts.sort(({missingCount:a}, {missingCount:b}) => b-a);
|
||||||
|
missingCounts.map((group) => {
|
||||||
|
if (group.missingCount > 0) {
|
||||||
|
description += `${group.name}: ${group.missingCount}\n`;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let missingCount = await this.CountMissingFromGroup(user.id);
|
embed.setDescription(description);
|
||||||
await interaction.editReply(JSON.stringify(missingCount));
|
await interaction.editReply({ embeds: [embed] });
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
async CountMissingFromGroup(userId) {
|
async CountMissingFromGroup(userId) {
|
||||||
@@ -64,8 +78,8 @@ module.exports = {
|
|||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
groupId: group.id,
|
id: group.id,
|
||||||
groupName: group.name,
|
name: group.name,
|
||||||
missingCount: missingCount,
|
missingCount: missingCount,
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user