xyter/src/helpers/generateCooldownName.ts
2023-05-28 16:06:21 +02:00

16 lines
525 B
TypeScript

import { ChatInputCommandInteraction, CommandInteraction } from "discord.js";
export default async (interaction: CommandInteraction) => {
const { commandName } = interaction;
if (interaction instanceof ChatInputCommandInteraction) {
const subcommandGroup = interaction.options.getSubcommandGroup();
const subcommand = interaction.options.getSubcommand();
return subcommandGroup
? `${commandName}-${subcommandGroup}-${subcommand}`
: `${commandName}-${subcommand}`;
}
return commandName;
};