Skip to content

Commit

Permalink
fix: 初始化失败
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-cn committed Jul 20, 2024
1 parent c79e65e commit b1ac618
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class App extends EventEmitter {
async renderMessage<T extends Message = Message>(template: string, message?: T) {
for (const render of this.renders) {
try {
template = await render(template, message);
template = <string>await render(template, message);
} catch (e: unknown) {
return `消息渲染失败:${(e as Error)?.message || '未知错误'}`;
}
Expand Down
12 changes: 7 additions & 5 deletions core/src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,14 @@ export class Command<A extends any[] = [], O = {}> {
message: Message<AD>,
template: string,
): Command.RunTime<AD, A, O> | void {
if (bot.command_prefix) {
if (!template.startsWith(bot.command_prefix)) return;
template = template.replace(bot.command_prefix, '');
}
let argv = this.parseSugar(template);
if (!argv.name) argv = this.parseArgv(template);
if (!argv.name) {
if (bot.command_prefix) {
if (!template.startsWith(bot.command_prefix)) return;
template = template.replace(bot.command_prefix, '');
}
argv = this.parseArgv(template);
}
if (argv.name !== this.name) {
if (this.aliasNames.includes(argv.name)) argv.name = this.name!;
else return;
Expand Down
8 changes: 7 additions & 1 deletion core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ export class Config<T extends object = object> {
},
set: (target, p, value, receiver) => {
if (Reflect.has(this, p)) return Reflect.set(this, p, value, receiver);
const result = Reflect.set(target, p, receiver);
const result = Reflect.set(target, p, value, receiver);
this.#saveConfig();
return result;
},
defineProperty: (target: T, property: string | symbol, attributes: PropertyDescriptor) => {
if (Reflect.has(this, property)) return Reflect.defineProperty(target, property, attributes);
const result = Reflect.defineProperty(target, property, attributes);
this.#saveConfig();
return result;
},
Expand Down
2 changes: 1 addition & 1 deletion packages/adapters/qq/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export function formatSendable(message: Sendable) {
...parseFromTemplate(item).map(ele => {
const { type, data } = ele;
return {
type,
...data,
type,
} as MessageElem;
}),
);
Expand Down
2 changes: 1 addition & 1 deletion zhin/src/plugins/commandParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ commandParser
.command('tip [name:string]')
.scope('private', 'group', 'guild', 'direct')
.desc('输出指令提示文本')
.alias('提示')
.sugar('提示')
.sugar(/^(\S+)提示$/, { args: ['$1'] })
.option('-H [showHidden:boolean] 显示隐藏指令')
.action(({ options, adapter, bot, message }, target) => {
Expand Down
2 changes: 1 addition & 1 deletion zhin/src/plugins/zhinManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const zhinManager = new Plugin('zhin管理');
zhinManager
.command('status')
.desc('查看知音运行状态')
.alias('状态')
.sugar('状态')
.action(({ adapter }) => {
const restartTimes = Number(process.env?.RESTART_TIMES);
const lastRestartTime = Date.now() - process.uptime() * 1000;
Expand Down

0 comments on commit b1ac618

Please sign in to comment.