Skip to content

Commit

Permalink
Add name to balance command
Browse files Browse the repository at this point in the history
  • Loading branch information
chiliec committed Aug 19, 2024
1 parent 56ad9ae commit 9714529
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/bot/features/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ const feature = composer.chatType("private")
feature.command("balance", logHandle("command-balance"), async ctx => {
const argument = ctx.match.trim()
let userId = ctx.dbuser.id
let { name } = ctx.dbuser
if (argument && isAdmin(ctx)) {
const [username] = argument.split(" ")
const user = await findUserByName(username.replace(/^@/, ""))
if (user) {
userId = user.id
name = user.name
}
}
const count = await countAllBalanceRecords()
Expand All @@ -32,7 +34,7 @@ feature.command("balance", logHandle("command-balance"), async ctx => {
getBalanceChangeTypeName(v.type),
v.createdAt ? formatDateTimeCompact(v.createdAt) : "",
])
const md = `
const md = `${name ? `@${name}'s balance` : ""}
\`\`\`\n${getMarkdownTable({
table: {
head: ["$CUBE", "Type", "Date"],
Expand Down

0 comments on commit 9714529

Please sign in to comment.