blob: 46f43627864e91c0857faccef0a7295579411432 [file] [log] [blame]
TheCodedProff86ba092023-01-27 17:10:07 -05001import type Discord from "discord.js";
2import client from "./client.js";
3
TheCodedProff86ba092023-01-27 17:10:07 -05004export const getCommandMentionByName = (name: string): string => {
Skyler Greyda16adf2023-03-05 10:22:12 +00005 const split = name.replaceAll("/", " ").split(" ");
TheCodedProff86ba092023-01-27 17:10:07 -05006 const commandName: string = split[0]!;
7
8 const filterCommand = (command: Discord.ApplicationCommand) => command.name === commandName;
9
Skyler Greyda16adf2023-03-05 10:22:12 +000010 const command = client.fetchedCommands.filter((c) => filterCommand(c));
TheCodedProff86ba092023-01-27 17:10:07 -050011 if (command.size === 0) return `\`/${name.replaceAll("/", " ")}\``;
12 const commandID = command.first()!.id;
13 return `</${split.join(" ")}:${commandID}>`;
Skyler Greyda16adf2023-03-05 10:22:12 +000014};
TheCodedProff86ba092023-01-27 17:10:07 -050015
Skyler Greyda16adf2023-03-05 10:22:12 +000016export const getCommandByName = (name: string): { name: string; description: string; mention: string } => {
17 const split = name.replaceAll(" ", "/");
TheCodedProff86ba092023-01-27 17:10:07 -050018 const command = client.commands["commands/" + split]!;
TheCodedProf8c295232023-01-27 20:52:24 -050019 // console.log(command)
TheCodedProff86ba092023-01-27 17:10:07 -050020 const mention = getCommandMentionByName(name);
21 return {
22 name: command[1].name,
23 description: command[1].description,
24 mention: mention
Skyler Greyda16adf2023-03-05 10:22:12 +000025 };
26};