mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-09 14:43:05 -04:00
[nextgen/cardstack] support flags for cardstack
This commit is contained in:
parent
ceb8eb097b
commit
47dcf378a9
2 changed files with 8 additions and 7 deletions
|
@ -21,7 +21,7 @@ module.exports = {
|
|||
* @returns {DynamicCardStack}
|
||||
*/
|
||||
createDynamicCardStack: (context, options)=>{
|
||||
return new DynamicCardStack(context, options)
|
||||
new DynamicCardStack(context, options);
|
||||
},
|
||||
CARD_STACK_CONSTANTS: require("./constants"),
|
||||
}
|
|
@ -44,7 +44,7 @@ class DynamicCardStack {
|
|||
* @param {boolean} options.pageNumbers Renders Page Numbers in the footer of all embeds in cards.
|
||||
* @param {Function} options.pageNumberGenerator Function that renders a page number. Default style is `Page <index>/<total>`
|
||||
* @param {boolean} options.disableCloning Disables cloning a card stack when someone other than the author interacts with it.
|
||||
* @param {boolean} options.ephemeral Makes the response ephemeral (primarily used by cloning)
|
||||
* @param {boolean} options.flags Flags that should be used for the response message.
|
||||
*/
|
||||
constructor(context, options) {
|
||||
this.context = context;
|
||||
|
@ -59,7 +59,7 @@ class DynamicCardStack {
|
|||
this.pageNumbers = options.pageNumbers || true;
|
||||
this.pageNumberGenerator = options.pageNumberGenerator || ((pg) => `Page ${pg.index + 1}/${pg.activeCardStack.length}`);
|
||||
this.disableCloning = options.disableCloning || false;
|
||||
this.ephemeral = options.ephemeral || false;
|
||||
this.flags = options.flags || 0;
|
||||
|
||||
this.rootIndex = this.index;
|
||||
this.killed = false;
|
||||
|
@ -73,7 +73,7 @@ class DynamicCardStack {
|
|||
this.lastInteraction = Date.now();
|
||||
this.spawned = 0;
|
||||
|
||||
return this._spawn();
|
||||
this._spawn();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,6 +87,7 @@ class DynamicCardStack {
|
|||
|
||||
// Remove reference to free the cardstack for GC
|
||||
activeStacks.delete(this.context.message || this.context.interaction);
|
||||
delete this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,7 +99,7 @@ class DynamicCardStack {
|
|||
return setTimeout(async () => {
|
||||
// If we have an interaction within the expiry window
|
||||
// restart the expiry window with 30s
|
||||
if((this.lastInteraction - this.spawned) >= 0){
|
||||
if((this.lastInteraction - this.spawned) > 0){
|
||||
clearTimeout(this.timeout)
|
||||
this.spawned = Date.now();
|
||||
// New expiry time is 30 seconds
|
||||
|
@ -210,7 +211,7 @@ class DynamicCardStack {
|
|||
}
|
||||
|
||||
// TODO: ensure flags don't get overwritten/allow supplying custom flags
|
||||
if (this.ephemeral) card.flags = MessageFlags.EPHEMERAL;
|
||||
card.flags = this.flags;
|
||||
|
||||
return card;
|
||||
} catch (e) {
|
||||
|
@ -276,7 +277,7 @@ class DynamicCardStack {
|
|||
reference: true,
|
||||
allowedMentions: {parse: [], repliedUser: false},
|
||||
// TODO: allow supplying flags
|
||||
flags: this.ephemeral ? MessageFlags.EPHEMERAL : 0
|
||||
flags: this.flags
|
||||
})
|
||||
} catch (e) {
|
||||
console.error("Message editing failed:")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue