Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/catplvsplus/pong-mc
Yet another Minecraft server status bot
https://github.com/catplvsplus/pong-mc
minecraft minecraft-server ping status-bot
Last synced: about 1 month ago
JSON representation
Yet another Minecraft server status bot
- Host: GitHub
- URL: https://github.com/catplvsplus/pong-mc
- Owner: catplvsplus
- License: gpl-3.0
- Created: 2023-06-12T09:58:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-06-12T11:18:09.000Z (over 1 year ago)
- Last Synced: 2024-08-08T17:28:25.895Z (3 months ago)
- Topics: minecraft, minecraft-server, ping, status-bot
- Language: TypeScript
- Homepage: https://discord.com/api/oauth2/authorize?client_id=903939319490826260&permissions=274878294080&scope=bot%20applications.commands
- Size: 74.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Introduction
Reciple is a discord.js command handler framework.
## Reciple Modules
Reciple scans the directory assigned in `reciple.yml` under `modules.modulesFolders` property. `modules.modulesFolders` can be the path of the folder of modules or glob pattern
### Folder Structure
##### Example Structure
```yml
# Modules configmodules:
modulesFolders:
- './modules' # Scans the modules folder for module files
``````
# Dir structuremodules/
├─ Module1.js
├─ Module2.js
```##### Example Structure with Glob patterns
```yml
# Modules configmodules:
modulesFolders:
- './modules' # Scans the modules folder for module files
- './modules/*' # Scans the folders of modules folder for module files
``````
# Dir structuremodules/
├─ moreModules/
│ ├─ Module1.js
│ ├─ Module2.js
├─ Module3.js
├─ Module4.js
```### Module Structure
Module files can be ES Modules or CommonJs.
##### Supported module file types
- `.js` *This can be an ESM or CJS*
- `.mjs`
- `.cjs`#### Module file structure
| Property | type | Required | Description |
|---|---|:---:|---|
| `versions` | `string\|string[]` | `true` | The versions of the Reciple client that the module script is compatible with. The versions can be a string or an array of strings. |
| `commands` | `(AnyCommandBuilder\|AnyCommandData)[]]` | `false` | The commands that are defined by the module script. |
| `onStart` | `(client: RecipleClient, module: RecipleModule) => Awaitable` | `true` | The function that is called when the module script is started. The function must return a boolean value or a promise that resolves to a boolean value. The boolean value indicates whether the module script was started successfully. |
| `onLoad` | `(client: RecipleClient, module: RecipleModule) => Awaitable` | `false` | The function that is called when the module script is loaded. |
| `onUnload` | `(unloadData: RecipleModuleUnloadData) => Awaitable` | `false` | The function that is called when the module script is unloaded. |#### ESM module example
```js
// Usage without classesexport default {
versions: '^7',
onStart: async client => {
return true;
},
onLoad: async client => {},
onUnload: async ({ client }) => {}
};
```
```js
// Usage with classesexport class MyModule {
versions = '^7';
commands = [];async onStart(client) {
return true;
}async onLoad(client) {}
async onUnload(unloadData) {}
}export default new MyModule();
```#### CommonJS module example
```js
// Usage without classesmodule.exports = {
versions: '^7',
onStart: async client => {
return true;
},
onLoad: async client => {},
onUnload: async ({ client }) => {}
};
```
```js
// Usage with classesclass MyModule {
versions = '^7';
commands = [];async onStart(client) {
return true;
}async onLoad(client) {}
async onUnload(unloadData) {}
}module.exports = new MyModule();
```## Reciple Commands
instead of importing builders from you'll need to import command builders from `reciple` or `@reciple/client`.
```diff
- const { SlashCommandBuilder, ContextMenuCommandBuilder } = require('discord.js');
- import { SlashCommandBuilder, ContextMenuCommandBuilder } from 'discord.js';
+ const { SlashCommandBuilder, ContextMenuCommandBuilder } = require('reciple');
+ import { SlashCommandBuilder, ContextMenuCommandBuilder } from 'reciple';
```You can add your commands in the commands property of your module script.
```js
export default {
versions: '^7',
commands: [
new SlashCommandBuilder()
.setName('ping')
.setDescription('Just a ping command')
.setExecute(async ({ interaction }) => {
await interaction.reply('Pong');
})
],
onStart: async client => {
return true;
}
};
```### Interaction command execute params
| Param | Type | Required | Description |
|---|---|:---:|---|
| `interaction` | `ChatInputCommandInteraction\|AnyContextMenuCommandInteraction` | `true` | The command interaction that triggers the command |
| `client` | `RecipleCommand` | `true` | The current bot client |
| `builder` | `AnySlashCommandBuilder\|ContextMenuCommandBuilder` | `true` | The builder of the executed command |
| `commandType` | `CommandType` | `true` | The type of executed command |### Message command execute params
| Param | Type | Required | Description |
|---|---|:---:|---|
| `message` | `Message` | `true` | The message that triggers the command |
| `client` | `RecipleCommand` | `true` | The current bot client |
| `builder` | `AnySlashCommandBuilder\|ContextMenuCommandBuilder` | `true` | The builder of the executed command |
| `commandType` | `CommandType` | `true` | The type of executed command |
| `options` | `MessageCommandOptionManager` | `true` | The parsed options passed to this command |### Handling command execute errors
Command halt function can handle command cooldown and errors. Return `true` if the error or cooldown is handled.
```js
new SlashCommandBuilder()
.setName('ping')
.setDescription('Just a ping command')
.setExecute(async ({ interaction }) => {
await interaction.reply('Pong');
})
.setHalt(async haltData => {
switch (haltData.reason) {
case CommandHaltReason.Cooldown:
await haltData.executeData.interaction.followUp('You\'ve been cooled-down');
return true;
case CommandHaltReason.Error:
await haltData.executeData.interaction.followUp('An error occured');
return true;
}// The rest is unhandled
})
```