1
0
mirror of https://github.com/hack-chat/main.git synced 2024-03-22 13:20:33 +08:00
hack-chat-main/commands/internal/socketreply.js
2024-01-08 11:09:59 -08:00

58 lines
1.6 KiB
JavaScript

/**
* @author Marzavec ( https://github.com/marzavec )
* @summary Bridge warning events to a user
* @version 1.0.0
* @description If a warning occurs within the server, this module will relay the warning to the
* client
* @module socketreply
*/
import {
Errors,
} from '../utility/_Constants.js';
/**
* Executes when invoked by a remote client
* @param {Object} env - Environment object with references to core, server, socket & payload
* @public
* @return {void}
*/
export async function run({ server, socket, payload }) {
if (payload.cmdKey !== server.cmdKey) {
// internal command attempt by client, increase rate limit chance and ignore
return server.police.frisk(socket, 20);
}
// send warning to target socket
return server.reply({
cmd: 'warn',
text: payload.text,
id: Errors.Global.INTERNAL_ERROR,
channel: false,
}, socket);
}
/**
* The following payload properties are required to invoke this module:
* "cmdKey", "text"
* @public
* @typedef {Array} socketreply/requiredData
*/
export const requiredData = ['cmdKey', 'text'];
/**
* Module meta information
* @public
* @typedef {Object} socketreply/info
* @property {string} name - Module command name
* @property {string} category - Module category name
* @property {string} description - Information about module
* @property {string} usage - Information about module usage
*/
export const info = {
name: 'socketreply',
category: 'internal',
description: 'Internally used to relay warnings to clients',
usage: 'Internal Use Only',
};