blob: da3e54b1584a0cb0aaf6fb964e9ed31702d4a51a [file] [log] [blame]
Samuel Shuert27bf3cd2023-03-03 15:51:25 -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 // console.log(command)
22 const mention = getCommandMentionByName(name);
23 return {
24 name: command[1].name,
25 description: command[1].description,
26 mention: mention
27 }
28}