From 1400f6eac49b8d0e1915ecfce4e7dc1b27d0f347 Mon Sep 17 00:00:00 2001 From: LenAnderson Date: Tue, 23 Apr 2024 12:40:17 -0400 Subject: [PATCH] add static fromProps --- public/scripts/slash-commands/SlashCommand.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/public/scripts/slash-commands/SlashCommand.js b/public/scripts/slash-commands/SlashCommand.js index 53f47366a..dcec5af8b 100644 --- a/public/scripts/slash-commands/SlashCommand.js +++ b/public/scripts/slash-commands/SlashCommand.js @@ -3,6 +3,27 @@ import { SlashCommandArgument, SlashCommandNamedArgument } from './SlashCommandA export class SlashCommand { + /** + * Creates a SlashCommand from a properties object. + * @param {Object} props + * @param {string} [props.name] + * @param {Function} [props.callback] + * @param {string} [props.helpString] + * @param {boolean} [props.interruptsGeneration] + * @param {boolean} [props.purgeFromMessage] + * @param {string[]} [props.aliases] + * @param {string} [props.returns] + * @param {SlashCommandNamedArgument[]} [props.namedArgumentList] + * @param {SlashCommandArgument[]} [props.unnamedArgumentList] + */ + static fromProps(props) { + const instance = Object.assign(new this(), props); + return instance; + } + + + + /**@type {string}*/ name; /**@type {Function}*/ callback; /**@type {string}*/ helpString;