mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
/member-get tweaks
This commit is contained in:
@ -736,16 +736,18 @@ export function initDefaultSlashCommands() {
|
|||||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||||
name: 'member-get',
|
name: 'member-get',
|
||||||
aliases: ['getmember', 'memberget'],
|
aliases: ['getmember', 'memberget'],
|
||||||
callback: (async ({field}, arg) => {
|
callback: (async ({field = 'name'}, arg) => {
|
||||||
if (!selected_group) {
|
if (!selected_group) {
|
||||||
toastr.warning('Cannot run /member-get command outside of a group chat.');
|
toastr.warning('Cannot run /member-get command outside of a group chat.');
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
if (field === undefined) {
|
if (field === '') {
|
||||||
throw new Error('\'/member-get field=\' argument required!');
|
toastr.warning('\'/member-get field=\' argument required!');
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
if (!['name', 'index', 'id', 'avatar'].includes(field)) {
|
if (!['name', 'index', 'id', 'avatar'].includes(field)) {
|
||||||
throw new Error(`Invalid '/member-get field=' argument '${field}' specified!`);
|
toastr.warning('\'/member-get field=\' argument required!');
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
const isId = !isNaN(parseInt(arg));
|
const isId = !isNaN(parseInt(arg));
|
||||||
const groupMember = findGroupMemberId(arg, true);
|
const groupMember = findGroupMemberId(arg, true);
|
||||||
@ -761,6 +763,7 @@ export function initDefaultSlashCommands() {
|
|||||||
description: 'Whether to retrieve the name, index, id, or avatar.',
|
description: 'Whether to retrieve the name, index, id, or avatar.',
|
||||||
typeList: [ARGUMENT_TYPE.STRING],
|
typeList: [ARGUMENT_TYPE.STRING],
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
|
defaultValue: 'name',
|
||||||
enumList: ['name', 'index', 'id', 'avatar'],
|
enumList: ['name', 'index', 'id', 'avatar'],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
Reference in New Issue
Block a user