Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mtripg6666tdr/oceanic-command-resolver
Message wrapper for oceanic.js to absorb the differences between Message and Interactions, with some helper classes included.
https://github.com/mtripg6666tdr/oceanic-command-resolver
Last synced: 10 days ago
JSON representation
Message wrapper for oceanic.js to absorb the differences between Message and Interactions, with some helper classes included.
- Host: GitHub
- URL: https://github.com/mtripg6666tdr/oceanic-command-resolver
- Owner: mtripg6666tdr
- License: mit
- Created: 2023-03-07T07:21:05.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-16T07:57:28.000Z (5 months ago)
- Last Synced: 2024-09-19T03:16:58.960Z (about 2 months ago)
- Language: TypeScript
- Homepage: https://npmjs.com/package/@mtripg6666tdr/oceanic-command-resolver
- Size: 146 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
> Note: this package is mainly for my own use, but it might be useful if you use as needed
# oceanic-command-resolver
![npm](https://img.shields.io/npm/v/@mtripg6666tdr/oceanic-command-resolver)Making a bot for Discord sometimes makes us feel it is difficult now, after the birth of slash-commands and other components.
However, all interaction emitted by those will be finally a Message, so all messages, command-interactions and components-interactions can be seen as some kind of "command", sent by users. This package was born from and based on this theory.This package will resolve all of `ComamndInteraction`, `ComponentInteraction` and `Message` as unified `CommandMessage` and you can code with `CommandMessage` with no considering the way the command was passed.
![oceanic-command-resolver-graph](https://user-images.githubusercontent.com/56076195/223353150-36136315-dd41-4e05-90d3-e79e4d0e0cdb.jpg)Therefore you can support Message-based-command, Component-based-command, and Interaction-based-command at once, without any redundant codes.
## Examples
- [Quick example to handle commands](example/index.js)
- [Create embed by using EmbedBuilder](example/embed.js)
- [Create message components by using MessageComponentBuilder](example/components.js)## API
### [`CommandMesasge`](https://web.usamyon.moe/oceanic-command-resolver/classes/CommandMessage.html)
Represence the message or interaction that includes command.
- `createFromMessage(message: Message, prefixLength?: number)`
Resolves message to CommandMessage.
- Return: [`CommandMesasge`](https://web.usamyon.moe/oceanic-command-resolver/classes/CommandMessage.html)- `createFromInteraction(interaction: CommandInteraction)`
Resolves message to CommandMessage.
- Return: [`CommandMesasge`](https://web.usamyon.moe/oceanic-command-resolver/classes/CommandMessage.html)
- `reply(options: MessageOptions)`
Reply to the user.
- Return: [`ResponseMessage`](https://web.usamyon.moe/oceanic-command-resolver/classes/ResponseMessage.html)
### [`ResponseMessage`](https://web.usamyon.moe/oceanic-command-resolver/classes/ResponseMessage.html)
Represence the message that is the reply to the CommandMessage.
- `edit(options: MessageContent)`
Edit the response message.
- Return: Promise<[`ResponseMessage`](https://web.usamyon.moe/oceanic-command-resolver/classes/ResponseMessage.html)>
*... and so on...*You can see the full api document [here](https://mtripg6666tdr.github.io/oceanic-command-resolver/).
## Versions
|oceanic-command-resolver|oceanic.js |
|------------------------|---------------|
|>=1.0.0 <1.2.0 |>=1.5.0 <1.7.0 |
|^1.2.0 |>=1.7.0 <1.8.0 |
|^1.3.0 |>=1.8.0 <1.9.0 |
|^1.4.0 |>=1.9.0 <1.12.0|> As of Jun 16, 2024
## License
[LICENSE](LICENSE)