add /member-get

a1abe14e02c0918411ba237af09363f4f836944b

Succubyss <87207237+Succubyss@users.noreply.github.com>

1 files changed, +41 -0Showing whitespace changes
public/scripts/slash-commands.js+41 -0
@@ -734,6 +734,47 @@ export function initDefaultSlashCommands() {
734 helpString: 'Unhides a message from the prompt.',734 helpString: 'Unhides a message from the prompt.',
735 }));735 }));
736 SlashCommandParser.addCommandObject(SlashCommand.fromProps({736 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
737 name: 'member-get',
738 aliases: ['getmember', 'memberget'],
739 callback: (async ({field}, arg) => {
740 if (!selected_group) {
741 toastr.warning('Cannot run /member-get command outside of a group chat.');
742 return '';
743 }
744 if (field === undefined) {
745 throw new Error('\'/member-get field=\' argument required!');
746 }
747 if (!['name', 'index', 'id', 'avatar'].includes(field)) {
748 throw new Error(`Invalid '/member-get field=' argument '${field}' specified!`);
749 }
750 const isId = !isNaN(parseInt(arg));
751 const groupMember = findGroupMemberId(arg, true);
752 if (!groupMember) {
753 toastr.warn(`No group member found using ${isId?'id':'string'} ${arg}`);
754 return '';
755 }
756 return groupMember[field];
757 }),
758 namedArgumentList: [
759 SlashCommandNamedArgument.fromProps({
760 name: 'field',
761 description: 'Whether to retrieve the name, index, id, or avatar.',
762 typeList: [ARGUMENT_TYPE.STRING],
763 isRequired: true,
764 enumList: ['name', 'index', 'id', 'avatar'],
765 }),
766 ],
767 unnamedArgumentList: [
768 SlashCommandArgument.fromProps({
769 description: 'member index (starts with 0), name, or avatar',
770 typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING],
771 isRequired: true,
772 enumProvider: commonEnumProviders.groupMembers(),
773 }),
774 ],
775 helpString: 'Retrieves a group member\'s name, index, id, or avatar.',
776 }));
777 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
737 name: 'member-disable',778 name: 'member-disable',
738 callback: disableGroupMemberCallback,779 callback: disableGroupMemberCallback,
739 aliases: ['disable', 'disablemember', 'memberdisable'],780 aliases: ['disable', 'disablemember', 'memberdisable'],