fix: status

This commit is contained in:
RainbowBird
2025-01-07 01:19:18 +08:00
parent b0dd132fbf
commit d4d1e8135a
+4 -3
View File
@@ -2,12 +2,13 @@ import type { BotContext, ComponentLifecycle } from '../composables/bot'
import { useLogg } from '@guiiai/logg'
import { registerCommand } from '../composables/command'
const status = new Map<string, string>()
export function getStatusToString(ctx: BotContext): string {
return Array.from(getStatus(ctx).entries()).map(([key, value]) => `${key}: ${value}`).join('\n')
}
export function getStatus(ctx: BotContext): Map<string, string> {
const status = new Map<string, string>()
const pos = ctx.bot.entity.position
const weather = ctx.bot.isRaining ? 'Rain' : ctx.bot.thunderState ? 'Thunderstorm' : 'Clear'
const timeOfDay = ctx.bot.time.timeOfDay < 6000
@@ -28,8 +29,8 @@ export function createStatusComponent(ctx: BotContext): ComponentLifecycle {
registerCommand('status', () => {
logger.log('Status command received')
const status = getStatus(ctx)
ctx.bot.chat(status.toString())
const status = getStatusToString(ctx)
ctx.bot.chat(status)
})
return {