blob: 2d4deb73b47d29945a795948e6b4436db59811f9 [file] [log] [blame]
TheCodedProff86ba092023-01-27 17:10:07 -05001import type Discord from "discord.js";
2import client from "./client.js";
3
4
5export const getCommandMentionByName = (name: string): string => {
6 const split = name.replaceAll("/", " ").split(" ")
7 const commandName: string = split[0]!;
8
9 const filterCommand = (command: Discord.ApplicationCommand) => command.name === commandName;
10
11 const command = client.fetchedCommands.filter(c => filterCommand(c))
12 if (command.size === 0) return `\`/${name.replaceAll("/", " ")}\``;
13 const commandID = command.first()!.id;
14 return `</${split.join(" ")}:${commandID}>`;
15}
16
17export const getCommandByName = (name: string): {name: string, description: string, mention: string} => {
18
19 const split = name.replaceAll(" ", "/")
20 const command = client.commands["commands/" + split]!;
TheCodedProffe0a7862023-01-27 20:36:35 -050021 console.log(command)
TheCodedProff86ba092023-01-27 17:10:07 -050022 const mention = getCommandMentionByName(name);
23 return {
24 name: command[1].name,
25 description: command[1].description,
26 mention: mention
27 }
28}