Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame] | 1 | import type Discord from "discord.js"; |
| 2 | import client from "./client.js"; |
| 3 | |
| 4 | |
| 5 | export 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 | |
| 17 | export 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 | } |