62 lines
2.2 KiB
TypeScript
62 lines
2.2 KiB
TypeScript
import { CommandMessage } from "../../../core/types/commands";
|
|
import type Amayo from "../../../core/client";
|
|
import { CouponService } from "../../../core/services/CouponService";
|
|
|
|
const OWNER_ID = "327207082203938818";
|
|
|
|
export const command: CommandMessage = {
|
|
name: "createcoupon",
|
|
type: "message",
|
|
aliases: ["gen-code", "cc"],
|
|
description: "Genera un nuevo cupón (Solo Owner)",
|
|
category: "Admin",
|
|
usage: "createcoupon <type> <value> [max_uses] [days_valid]",
|
|
run: async (message, args, client: Amayo) => {
|
|
if (message.author.id !== OWNER_ID) {
|
|
await message.reply("❌ No tienes permiso para usar este comando.");
|
|
return;
|
|
}
|
|
|
|
if (args.length < 2) {
|
|
await message.reply(
|
|
"❌ Uso: `!createcoupon <type> <value> [max_uses] [days_valid]`\n" +
|
|
"Tipos: `IMPORT_LIMIT`, `VOLUME_BOOST`, `PRO_RECOMMENDATIONS`, `ALL_ACCESS`"
|
|
);
|
|
return;
|
|
}
|
|
|
|
const type = args[0].toUpperCase();
|
|
const value = parseInt(args[1]);
|
|
const maxUses = args[2] ? parseInt(args[2]) : 1;
|
|
const daysValid = args[3] ? parseInt(args[3]) : 30;
|
|
|
|
const validTypes = ["IMPORT_LIMIT", "VOLUME_BOOST", "PRO_RECOMMENDATIONS", "ALL_ACCESS"];
|
|
if (!validTypes.includes(type)) {
|
|
await message.reply(`❌ Tipo inválido. Tipos válidos: ${validTypes.join(", ")}`);
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const coupon = await CouponService.createCoupon(
|
|
type,
|
|
value,
|
|
maxUses,
|
|
daysValid,
|
|
message.author.id
|
|
);
|
|
|
|
await message.reply(
|
|
`✅ **Cupón Creado Exitosamente**\n` +
|
|
`🎫 Código: \`${coupon.code}\`\n` +
|
|
`📦 Tipo: ${type}\n` +
|
|
`💎 Valor: ${value}\n` +
|
|
`👥 Usos Máximos: ${maxUses}\n` +
|
|
`📅 Días de Validez: ${daysValid}`
|
|
);
|
|
} catch (error: any) {
|
|
console.error("Error creating coupon:", error);
|
|
await message.reply(`❌ Error al crear cupón: ${error.message}`);
|
|
}
|
|
},
|
|
};
|