Dialog shennanegins

TIL the button callbacks for Dialog.prompt and Dialog.confirm can be asynchronous.
const foo = async () => {
const response = await Dialog.prompt({
title: "Confirmation Title",
content: "Are you sure about that?",
callback: async (html) => { return 'foo' },
});

console.log('responded', response); // 'foo' when the button is pressed
};

foo()
const foo = async () => {
const response = await Dialog.prompt({
title: "Confirmation Title",
content: "Are you sure about that?",
callback: async (html) => { return 'foo' },
});

console.log('responded', response); // 'foo' when the button is pressed
};

foo()
C
Calego887d ago
const refrain = () => Dialog.prompt({
content: "It just goes on and on my friends.",
callback: chorus
});

const chorus = () => Dialog.prompt({
content: "This is the song that never ends.",
callback: refrain
});

chorus();
const refrain = () => Dialog.prompt({
content: "It just goes on and on my friends.",
callback: chorus
});

const chorus = () => Dialog.prompt({
content: "This is the song that never ends.",
callback: refrain
});

chorus();
No description
DT
Daniel Thorp887d ago
Can you pass the html between the two as well?
C
Calego887d ago
Yeah! the argument of the callback is the html
C
Calego887d ago
const annoying = () => Dialog.confirm({
content: "Press yes or I come back.",
no: annoying
});

annoying();
const annoying = () => Dialog.confirm({
content: "Press yes or I come back.",
no: annoying
});

annoying();
No description
C
Calego887d ago
hard to see what's happening here, but each one is actually adding one to the nested dom stack.
function outerHTML(node){
return node.outerHTML || new XMLSerializer().serializeToString(node);
}

const inception = (html) => Dialog.prompt({
content: html[0] instanceof Node ? outerHTML(html[0]) : html[0],
callback: inception
});


inception(["We have to go deeper."]);
function outerHTML(node){
return node.outerHTML || new XMLSerializer().serializeToString(node);
}

const inception = (html) => Dialog.prompt({
content: html[0] instanceof Node ? outerHTML(html[0]) : html[0],
callback: inception
});


inception(["We have to go deeper."]);
No description
Want results from more Discord servers?
Add your server
More Posts