mirror of
https://github.com/xHyroM/bun-discord-bot.git
synced 2024-11-10 01:08:07 +01:00
Add file name with line numbers when sending code block message. (#30)
This commit is contained in:
parent
8ff1bdaee3
commit
b8f0721eb8
2 changed files with 2 additions and 2 deletions
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
|
@ -3,7 +3,7 @@ import { defineListener } from "../loaders/listeners.ts";
|
|||
import { MESSAGE_PREFIX, BUN_ONLY_CHANNEL_ID } from "../constants.ts";
|
||||
import { COMMANDS } from "../loaders/commands.ts";
|
||||
import { MessageCommandContext } from "../structs/context/CommandContext.ts";
|
||||
import { extname } from "node:path";
|
||||
import { extname, basename } from "node:path";
|
||||
import { safeSlice } from "../util.ts";
|
||||
|
||||
const GITHUB_LINE_URL_REGEX = /(?:https?:\/\/)?(?:www\.)?(?:github)\.com\/(?<repo>[a-zA-Z0-9-_]+\/[A-Za-z0-9_.-]+)\/blob\/(?<path>.+?)#L(?<first_line_number>\d+)[-~]?L?(?<second_line_number>\d*)/i;
|
||||
|
@ -90,7 +90,7 @@ async function handleGithubLink(message: Message) {
|
|||
if (extension === "zig") extension = "rs";
|
||||
|
||||
message.reply({
|
||||
content: `\`\`\`${extension}\n${safeSlice(text, 2000 - 6 - extension.length)}\n\`\`\``,
|
||||
content: `***${basename(path)}*** — *(L${firstLineNumber}${secondLineNumber ? `-L${secondLineNumber}` : ""})*\n\`\`\`${extension}\n${safeSlice(text, 2000 - 6 - extension.length)}\n\`\`\``,
|
||||
components: [
|
||||
new ActionRowBuilder<ButtonBuilder>()
|
||||
.setComponents(
|
||||
|
|
Loading…
Reference in a new issue