blob: e5a67c51977a1f10211728043d769ef1b97001a9 [file] [log] [blame]
PineaFan0d06edc2023-01-17 22:10:31 +00001import type Discord from "discord.js";
2import client from "./client.js";
PineaFan0d06edc2023-01-17 22:10:31 +00003
4
5export const getCommandMentionByName = async (name: string): Promise<string> => {
6 const split = name.replaceAll("/", " ").split(" ")
7 const commandName: string = split[0]!;
PineaFan0d06edc2023-01-17 22:10:31 +00008
9 const filterCommand = (command: Discord.ApplicationCommand) => command.name === commandName;
10
PineaFand471ccd2023-01-26 20:48:40 +000011 const command = client.commandList!.filter(c => filterCommand(c))
12 if (command.size === 0) return `\`/${name.replaceAll("/", " ")}\``;
13 const commandID = command.first()!.id;
PineaFan0d06edc2023-01-17 22:10:31 +000014 return `</${split.join(" ")}:${commandID}>`;
PineaFand471ccd2023-01-26 20:48:40 +000015}