Skip to content

Commit 02c7643

Browse files
committed
Improve docs
1 parent 2dd2615 commit 02c7643

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,35 @@ bot.registerAction("image", async ({ createEmbed, asyncEffect }) => {
286286
});
287287
```
288288

289+
### Triggering actions inside actions
290+
291+
ActionParameters include a `runAction` callback which can be used to manually invoke an action through the DJS pipeline, thus fully supporting `asyncEffect` and message component subscriptions.
292+
293+
You need a `ResponseAction` and `ActionParameters` to call this. You may reuse the action's `ActionParameters`, be aware that reusing `asyncEffect` or `subscribe`'s `ActionParameters` will have the side-effect of making it seem like the Bot is the one calling the action (ergo, making components unclickable to users)
294+
295+
```ts
296+
//test action can include asyncEffect calls and components!
297+
const testAction = () => "hello!";
298+
bot.on("coolAction", (params) => {
299+
const { subscribe, createEmbed } = params;
300+
/* `runAction` is also available here! ^*/
301+
302+
const buttonRow = subscribe(
303+
{
304+
label: "Press me",
305+
style: "PRIMARY",
306+
},
307+
({ runAction }) => {
308+
runAction(testAction, params);
309+
}
310+
);
311+
return createEmbed({
312+
desc: "Press the button to be greeted",
313+
components: [buttonRow],
314+
});
315+
});
316+
```
317+
289318
### Error handling
290319

291320
DJS-diy offers per-action and global approaches to error handling.

0 commit comments

Comments
 (0)