blob: 0d4ac479b54ca4ddd1a3392b03049e77b9d46a8a [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]!;
21 const mention = getCommandMentionByName(name);
22 return {
23 name: command[1].name,
24 description: command[1].description,
25 mention: mention
26 }
27}