Skip to content

Commit

Permalink
fix(messageDelete): top rounded corner always being ├, embeds follow …
Browse files Browse the repository at this point in the history
…the ┊ indent
  • Loading branch information
AtoraSuunva committed Nov 18, 2024
1 parent 3d0a081 commit 11f31ef
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions src/mod/modlog/handlers/messageDelete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,14 @@ export async function messageToLog(
(interaction.type === InteractionType.ApplicationCommand ? '/' : '') +
interaction.commandName

hasUpper = true
lines.push(
`╭╼ ${formatLogUser(interaction.user)} used ${ansiFormat(TextColor.Blue, commandName)}`,
)
hasUpper = true
}

if (includeReference && message.reference?.messageId) {
const ref = await message.fetchReference().catch(() => null)
hasUpper = true

if (ref) {
const preview =
Expand All @@ -278,6 +277,7 @@ export async function messageToLog(
`${hasUpper ? '├' : '╭'}╼ Original message was deleted (${message.reference.messageId})`,
)
}
hasUpper = true
}

if (includeUser) {
Expand Down Expand Up @@ -379,13 +379,6 @@ export async function messageToLog(
}
}

const TL_CHAR = '╭'
const TR_CHAR = '╮'
const BL_CHAR = '╰'
const BR_CHAR = '╯'
const H_CHAR = '─'
const V_CHAR = '│'

interface ToEmbedOptions {
minimal?: boolean
}
Expand Down Expand Up @@ -440,23 +433,21 @@ function embedToLog(

if (minimal) {
for (let i = 0; i < lines.length; i++) {
lines[i] = `${ansiFormat(TextColor.Cyan, V_CHAR)} ${lines[i]}`
lines[i] = `${ansiFormat(TextColor.Cyan, '│')} ${lines[i]}`
}

lines.unshift(
ansiFormat(TextColor.Cyan, `${TL_CHAR}${H_CHAR} Embed ${H_CHAR}`),
)
lines.push(ansiFormat(TextColor.Cyan, `${BL_CHAR}${H_CHAR.repeat(9)}`))
lines.unshift(`┊ ${ansiFormat(TextColor.Cyan, '╭─ Embed ┈┄╌')}`)
lines.push(`┊ ${ansiFormat(TextColor.Cyan, '╰────────┈┄╌')}`)
} else {
const maxLineLength = Math.max(...lines.map((l) => l.length), 0)
const boxWidth = maxLineLength + 2

for (let i = 0; i < lines.length; i++) {
lines[i] = `${V_CHAR} ${lines[i].padEnd(maxLineLength)} ${V_CHAR}`
lines[i] = `┊ │ ${lines[i].padEnd(maxLineLength)} `
}

lines.unshift(`${TL_CHAR}${H_CHAR.repeat(boxWidth)}${TR_CHAR}`)
lines.push(`${BL_CHAR}${H_CHAR.repeat(boxWidth)}${BR_CHAR}`)
lines.unshift(`┊ ╭${'─'.repeat(boxWidth)}`)
lines.push(`┊ ╰${'─'.repeat(boxWidth)}`)
}

return lines.join('\n')
Expand Down

0 comments on commit 11f31ef

Please sign in to comment.