Docs: Add docs for collection and view commands
This commit is contained in:
@@ -97,6 +97,15 @@ module.exports = {
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A function to generate pagination components with optional features.
|
||||||
|
*
|
||||||
|
* @param {string} uid - The unique (component)ID for the pagination.
|
||||||
|
* @param {boolean} [prev=true] - Whether the "Previous" button should be enabled or disabled. Defaults to true.
|
||||||
|
* @param {boolean} [next=true] - Whether the "Next" button should be enabled or disabled. Defaults to true.
|
||||||
|
* @param {boolean} [groupDupes=false] - Whether the "Group Dupes" button should be checked or unchecked. Defaults to false (unchecked).
|
||||||
|
* @returns {ActionRowBuilder} An ActionRowBuilder object containing three ButtonBuilder objects for "Previous", "Next", and "Group Dupes" buttons. .
|
||||||
|
*/
|
||||||
getPaginateComponents(uid, prev=true, next=true, groupDupes=false) {
|
getPaginateComponents(uid, prev=true, next=true, groupDupes=false) {
|
||||||
//add buttons for pagination
|
//add buttons for pagination
|
||||||
let row = new ActionRowBuilder();
|
let row = new ActionRowBuilder();
|
||||||
@@ -122,6 +131,19 @@ module.exports = {
|
|||||||
return row;
|
return row;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the page embed of a user's card collection with pagination and filtering.
|
||||||
|
* This method has the side-effect of actively updating the passed embed!
|
||||||
|
*
|
||||||
|
* @function updatePageEmbed
|
||||||
|
* @param {string} uid - The unique (component)ID of the embed components.
|
||||||
|
* @param {Object} i - The embed message object.
|
||||||
|
* @param {Object} user - The user object (discord snowflake).
|
||||||
|
* @param {number} offset - The offset to start pagination.
|
||||||
|
* @param {boolean} group - True if cards should be grouped by character, false otherwise.
|
||||||
|
* @param {Object} filterParam - An object containing filters (character, group, and quality) to apply.
|
||||||
|
* @returns {Promise<void>} A promise that resolves when the embed is updated.
|
||||||
|
*/
|
||||||
async updatePageEmbed(uid, i, user, offset, group, filterParam) {
|
async updatePageEmbed(uid, i, user, offset, group, filterParam) {
|
||||||
let cards;
|
let cards;
|
||||||
let filter = {
|
let filter = {
|
||||||
@@ -136,6 +158,7 @@ module.exports = {
|
|||||||
offset: offset
|
offset: offset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//The parameter "group" refers to character grouping and is unrelated to the entity of type group!!
|
||||||
if (group) {
|
if (group) {
|
||||||
filter["attributes"] = ["characterId", [Card.sequelize.fn("COUNT", "characterId"), "count"]];
|
filter["attributes"] = ["characterId", [Card.sequelize.fn("COUNT", "characterId"), "count"]];
|
||||||
filter["order"] = [[Card.sequelize.literal("count"), "DESC"]];
|
filter["order"] = [[Card.sequelize.literal("count"), "DESC"]];
|
||||||
|
|||||||
@@ -50,6 +50,12 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* View a card by its identifier and create an embed for it
|
||||||
|
* @param {Interaction} interaction - The interaction object that triggered this function
|
||||||
|
* @param {string} cardIdentifier - The identifier of the card to view
|
||||||
|
* @returns {Promise<void>} - A promise that resolves once the card has been viewed and an embed has been created
|
||||||
|
*/
|
||||||
async viewCard(interaction, cardIdentifier) {
|
async viewCard(interaction, cardIdentifier) {
|
||||||
let card = await Card.findOne({
|
let card = await Card.findOne({
|
||||||
where: {
|
where: {
|
||||||
@@ -105,6 +111,15 @@ module.exports = {
|
|||||||
const message = await interaction.editReply({ embeds: [embed], files: [cardImage], fetchReply: true });
|
const message = await interaction.editReply({ embeds: [embed], files: [cardImage], fetchReply: true });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* View a character by its ID and create an embed for it.
|
||||||
|
* If the member who triggered the interaction is an admin, also include an "Edit" button.
|
||||||
|
* (Edits the passed interaction reply)
|
||||||
|
*
|
||||||
|
* @param {Interaction} interaction - The interaction object that triggered this function.
|
||||||
|
* @param {number} characterId - The ID of the character to view.
|
||||||
|
* @returns {Promise<void>} - A promise that resolves once the character has been viewed and an embed has been created.
|
||||||
|
*/
|
||||||
async viewCharacter(interaction, characterId) {
|
async viewCharacter(interaction, characterId) {
|
||||||
let isAdmin = await UserUtils.getPermissionLevel(interaction.member) == 2;
|
let isAdmin = await UserUtils.getPermissionLevel(interaction.member) == 2;
|
||||||
let character = await Character.findOne({
|
let character = await Character.findOne({
|
||||||
@@ -161,6 +176,8 @@ module.exports = {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
let replyPayload = { embeds: [embed], files: [imagePath], fetchReply: true }
|
let replyPayload = { embeds: [embed], files: [imagePath], fetchReply: true }
|
||||||
|
|
||||||
|
//the experimental Edit button is added if view is invoked by an admin
|
||||||
if (isAdmin) { replyPayload.components = [row]; }
|
if (isAdmin) { replyPayload.components = [row]; }
|
||||||
const message = await interaction.editReply(replyPayload);
|
const message = await interaction.editReply(replyPayload);
|
||||||
const filter = (m) => m.member.user.id === interaction.member.user.id;
|
const filter = (m) => m.member.user.id === interaction.member.user.id;
|
||||||
@@ -174,6 +191,15 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* View a badge by its ID and create an embed for it
|
||||||
|
* (Edits the passed interaction reply)
|
||||||
|
*
|
||||||
|
* @async
|
||||||
|
* @param {Interaction} interaction - The interaction object that triggered this function
|
||||||
|
* @param {number} badgeId - The ID of the badge to view
|
||||||
|
* @returns {Promise<void>} - A promise that resolves once the badge has been viewed and an embed has been created
|
||||||
|
*/
|
||||||
async viewBadge(interaction, badgeId) {
|
async viewBadge(interaction, badgeId) {
|
||||||
let badge = await Badge.findOne({
|
let badge = await Badge.findOne({
|
||||||
where: { id: badgeId },
|
where: { id: badgeId },
|
||||||
|
|||||||
Reference in New Issue
Block a user