Skip to content

Commit

Permalink
Merge branch 'main' of github.com:moonlight-mod/moonlight-mod.github.io
Browse files Browse the repository at this point in the history
  • Loading branch information
NotNite committed Jan 20, 2025
2 parents 81e0355 + 10d36c0 commit a39e3ce
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/content/docs/ext-dev/cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,24 @@ import { UserStore } from "@moonlight-mod/wp/common_stores";

console.log(UserStore.getCurrentUser());
```

## Modifying message content before it is sent

Remember to add `commands` to your manifest's dependencies and `{ext: "commands", id: "commands"}` to your Webpack module's dependencies.

```ts
import Commands from "@moonlight-mod/wp/commands_commands";

Commands.registerLegacyCommand("unique-id", {
// This can be a more specific regex, but this only tells it to run if it
// finds anything that matches this regex within the message.
// You will have to do your own extraction and processing if you want to do
// something based on a specific string.
match: /.*/,
action: (content, context) => {
// Modify the content

return {content};
}
})
```

0 comments on commit a39e3ce

Please sign in to comment.