TheCodedProf | f86ba09 | 2023-01-27 17:10:07 -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]!; |
TheCodedProf | fe0a786 | 2023-01-27 20:36:35 -0500 | [diff] [blame^] | 21 | console.log(command) |
TheCodedProf | f86ba09 | 2023-01-27 17:10:07 -0500 | [diff] [blame] | 22 | const mention = getCommandMentionByName(name); |
| 23 | return { |
| 24 | name: command[1].name, |
| 25 | description: command[1].description, |
| 26 | mention: mention |
| 27 | } |
| 28 | } |