[nextgen] initial cardstack work

This commit is contained in:
bignutty 2025-02-11 20:45:41 +01:00
parent 858a810e86
commit 043c65a36c
4 changed files with 367 additions and 11 deletions

View file

@ -1,7 +1,7 @@
const { prideborder } = require("#api");
const { createEmbed, page } = require("#utils/embed");
const { acknowledge } = require("#utils/interactions");
const { editOrReply } = require("#utils/message");
const DynamicCardStack = require("../../../labscore/cardstack/DynamicCardStack");
module.exports = {
label: "text",
@ -17,8 +17,55 @@ module.exports = {
onCancel: ()=>{},
run: async (context, args) => {
await acknowledge(context);
const a = await prideborder(context, "https://cdn.discordapp.com/emojis/1145727546747535412.png?size=4096")
editOrReply(context, "ok");
try{
// This will create a new dynamic card stack
new DynamicCardStack(context, {
cards: [
createEmbed("default", context, { description: "page 1"}),
createEmbed("default", context, { description: "page 2. this has a conditional button."})
].map((p, index)=>page(p, {}, { key: `t_${index}` })),
interactive: {
conditional_button: {
// Button Label
label: "Conditional",
// Next to pagination or new row
inline: false,
visible: (page) => {
console.log(page.getAllState());
console.log(page.getState("t_1"));
return (page.getState("key") === "t_1")
},
resolvePage: (page) => {
return [
createEmbed("default", context, { description: "this is a conditional sub page"})
].map((p)=>page(p));
}
},
dynamic_button: {
// Button Label
label: (page) => {
return page.getState("key");
},
// Next to pagination or new row
inline: false,
visible: true,
// Renders the loading state card
renderLoadingState: (page) => {
return createEmbed("default", context, {
description: "-# Subpage Loading :)",
})
},
resolvePage: (page) => {
return [
createEmbed("default", context, { description: "this is a conditional sub page"})
].map((p)=>page(p));
}
}
}
})
}catch(e){
console.log(e)
}
}
};