blob: e5a67c51977a1f10211728043d769ef1b97001a9 [file] [log] [blame]
import type Discord from "discord.js";
import client from "./client.js";
export const getCommandMentionByName = async (name: string): Promise<string> => {
const split = name.replaceAll("/", " ").split(" ")
const commandName: string = split[0]!;
const filterCommand = (command: Discord.ApplicationCommand) => command.name === commandName;
const command = client.commandList!.filter(c => filterCommand(c))
if (command.size === 0) return `\`/${name.replaceAll("/", " ")}\``;
const commandID = command.first()!.id;
return `</${split.join(" ")}:${commandID}>`;
}