Skip to content

获取角色卡 ​

:::tip请务必先阅读如何正确使用酒馆助手 :::

点击查看对应类型定义文件 (可发给 AI 或 IDE 使用, 酒馆助手界面中提供了打包下载)

getCharacterNames ​

获取角色卡的显示名称列表

ts
function getCharacterNames(): string[];

返回值 ​

  • 角色卡的显示名称列表, 如 ['少女歌剧', '少女歌剧', '神乐光']: string[]

getCharacterIds ​

获取角色卡的头像 id 列表

ts
function getCharacterIds(): string[];

返回值 ​

  • 角色卡的头像 id 列表, 也是角色卡的文件名称列表, 如 ['少女歌剧.png', '少女歌剧_1.png', '神乐光.png']: string[]

getCurrentCharacterName ​

ts
function getCurrentCharacterName(): string | null;

返回值 ​

  • 角色卡的显示名称: string|null; 如果当前没有角色卡, 则返回 null

getCurrentCharacterId ​

ts
function getCurrentCharacterId(): string | null;

返回值 ​

  • 角色卡的头像 id, 也是角色卡的文件名称: string|null; 如果当前没有角色卡, 则返回 null

getCharacter ​

获取 character_name_or_id 角色卡的内容

ts
async function getCharacter(character_name_or_id: LiteralUnion<'current', string | `${string}.png`>): Promise<Character>;
ts
type Character = {
  name: string;
  version: string;
  creator: string;
  creator_notes: string;

  worldbook: string | null;
  description: string;
  first_messages: string[];

  extensions: {
    regex_scripts: TavernRegex[];
    tavern_helper: {
      scripts: Record<string, any>[];
      variables: Record<string, any>;
    };
    [other: string]: any;
  };
};

参数 ​

character_name_or_id ​

  • 类型: 'current' | string | `${string}.png`
  • 描述: 角色卡显示名称 (如 '少女歌剧') 或头像 id (角色卡文件名, 如 '少女歌剧.png'); 'current' 表示当前打开的角色卡

返回值 ​

异常 ​

  • 如果角色卡不存在, 将会抛出错误