| import type Discord from "discord.js"; |
| import client from "./client.js"; |
| |
| |
| export const getCommandMentionByName = (name: string): string => { |
| const split = name.replaceAll("/", " ").split(" ") |
| const commandName: string = split[0]!; |
| |
| const filterCommand = (command: Discord.ApplicationCommand) => command.name === commandName; |
| |
| const command = client.fetchedCommands.filter(c => filterCommand(c)) |
| if (command.size === 0) return `\`/${name.replaceAll("/", " ")}\``; |
| const commandID = command.first()!.id; |
| return `</${split.join(" ")}:${commandID}>`; |
| } |
| |
| export const getCommandByName = (name: string): {name: string, description: string, mention: string} => { |
| |
| const split = name.replaceAll(" ", "/") |
| const command = client.commands["commands/" + split]!; |
| const mention = getCommandMentionByName(name); |
| return { |
| name: command[1].name, |
| description: command[1].description, |
| mention: mention |
| } |
| } |