Skip to content

Commit 10d36c0

Browse files
committed
cookbook: Add modifying content before send recipe
1 parent e88d868 commit 10d36c0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/content/docs/ext-dev/cookbook.md

+21
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,24 @@ import { UserStore } from "@moonlight-mod/wp/common_stores";
149149

150150
console.log(UserStore.getCurrentUser());
151151
```
152+
153+
## Modifying message content before it is sent
154+
155+
Remember to add `commands` to your manifest's dependencies and `{ext: "commands", id: "commands"}` to your Webpack module's dependencies.
156+
157+
```ts
158+
import Commands from "@moonlight-mod/wp/commands_commands";
159+
160+
Commands.registerLegacyCommand("unique-id", {
161+
// This can be a more specific regex, but this only tells it to run if it
162+
// finds anything that matches this regex within the message.
163+
// You will have to do your own extraction and processing if you want to do
164+
// something based on a specific string.
165+
match: /.*/,
166+
action: (content, context) => {
167+
// Modify the content
168+
169+
return {content};
170+
}
171+
})
172+
```

0 commit comments

Comments
 (0)