diff --git a/src/discord/bot/commands/webhooks/DeleteWebhookCommand.ts b/src/discord/bot/commands/webhooks/DeleteWebhookCommand.ts index 0e672240..4e6efdac 100644 --- a/src/discord/bot/commands/webhooks/DeleteWebhookCommand.ts +++ b/src/discord/bot/commands/webhooks/DeleteWebhookCommand.ts @@ -25,8 +25,13 @@ export default class extends Command { return; } + const getChannelName = (id: string) => { + const channel = this.client.channels.cache.get(id); + return channel?.toString() || `#${id}`; + }; + if (!input.value || typeof input.value !== "string") { - await interaction.respond(config.webhooks.map((webhook) => ({ name: webhook.id, value: webhook.id }))); + await interaction.respond(config.webhooks.map((webhook) => ({ name: getChannelName(webhook.id), value: webhook.id }))); return; } @@ -34,7 +39,7 @@ export default class extends Command { const allOptions = config.webhooks.map((webhook) => webhook.id); const options = allOptions.filter((opt) => opt.startsWith(inputValue) || opt.endsWith(inputValue) || opt.includes(inputValue)); - await interaction.respond(options.map((opt) => ({ name: opt, value: opt }))); + await interaction.respond(options.map((opt) => ({ name: getChannelName(opt), value: opt }))); } public override async run(interaction: CommandInteraction<"cached">) { diff --git a/src/discord/bot/commands/webhooks/GetSecretCommand.ts b/src/discord/bot/commands/webhooks/GetSecretCommand.ts index 084a55cf..71f69743 100644 --- a/src/discord/bot/commands/webhooks/GetSecretCommand.ts +++ b/src/discord/bot/commands/webhooks/GetSecretCommand.ts @@ -25,8 +25,13 @@ export default class extends Command { return; } + const getChannelName = (id: string) => { + const channel = this.client.channels.cache.get(id); + return channel?.toString() || `#${id}`; + }; + if (!input.value || typeof input.value !== "string") { - await interaction.respond(config.webhooks.map((webhook) => ({ name: webhook.id, value: webhook.id }))); + await interaction.respond(config.webhooks.map((webhook) => ({ name: getChannelName(webhook.id), value: webhook.id }))); return; } @@ -34,7 +39,7 @@ export default class extends Command { const allOptions = config.webhooks.map((webhook) => webhook.id); const options = allOptions.filter((opt) => opt.startsWith(inputValue) || opt.endsWith(inputValue) || opt.includes(inputValue)); - await interaction.respond(options.map((opt) => ({ name: opt, value: opt }))); + await interaction.respond(options.map((opt) => ({ name: getChannelName(opt), value: opt }))); } public override async run(interaction: CommandInteraction<"cached">) { diff --git a/src/github/lib/GitHubManager.ts b/src/github/lib/GitHubManager.ts index d2cf5010..256df273 100644 --- a/src/github/lib/GitHubManager.ts +++ b/src/github/lib/GitHubManager.ts @@ -1,4 +1,4 @@ -import type GitCordClient from "../../discord/lib/GitCordClient.js"; +import type GitCordClient from "#discord/lib/GitCordClient.js"; import GitHubEmbedLoader from "./embed/GitHubEmbedLoader.js"; import GitHubWebhookManager from "./webhook/GitHubWebhookManager.js"; diff --git a/src/github/lib/webhook/GitHubWebhookManager.ts b/src/github/lib/webhook/GitHubWebhookManager.ts index ab97e516..563920f4 100644 --- a/src/github/lib/webhook/GitHubWebhookManager.ts +++ b/src/github/lib/webhook/GitHubWebhookManager.ts @@ -11,7 +11,7 @@ import { RequestManager, RequestMethod } from "@discordjs/rest"; import BodyParser from "body-parser"; export default class GitHubWebhookManager { - public requestManager = new RequestManager({}); + public requestManager = new RequestManager({ userAgentAppendix: "GitCord (https://github.com/ijsKoud/gitcord)" }); public constructor(public client: GitCordClient, public manager: GitHubManager) {} @@ -51,7 +51,7 @@ export default class GitHubWebhookManager { ); }; - this.client.logger.info(`[GITHUB]: Smee.io connection ready for event listening.`); + this.client.logger.info("[GITHUB]: Smee.io connection ready for event listening."); } private initProd() { @@ -60,7 +60,7 @@ export default class GitHubWebhookManager { .use(BodyParser.json()) .post("/webhook/:guildId/:webhookId", this.handleRequest.bind(this)) .get("*", (_, res) => res.redirect("https://ijskoud.dev/github/gitcord")) - .listen(Number(process.env.PORT), () => this.client.logger.info(`[GITHUB]: Webhook server ready for event listening.`)); + .listen(Number(process.env.PORT), () => this.client.logger.info("[GITHUB]: Webhook server ready for event listening.")); } private async handleRequest(req: Request, res: Response) {