wsb-bott / src /commands /deleteDrop.js
APRKDEV's picture
Upload 43 files
e5c9966 verified
const { createEmbed } = require('../utils/embeds');
const { Colors } = require('../config');
const { stmts } = require('../database');
const fetch = require('node-fetch');
/**
* usage: deletedrop <id>
*/
module.exports = {
async execute(client, message, args) {
if (args.length < 1) {
return message.reply({ content: '❌ Usage: `deletedrop <id>`' });
}
const id = parseInt(args[0]);
if (isNaN(id)) return message.reply({ content: '❌ Invalid Drop ID. Must be a number.' });
const drop = await stmts.getWebDrop(id);
if (!drop) {
return message.reply({ content: `❌ No drop found in database with ID: **${id}**` });
}
try {
// 1. Delete from Supabase
await stmts.deleteWebDrop(id);
// 2. Send DELETE request to Website Backend API
const WEBSITE_API = process.env.WEBSITE_API_URL || 'http://localhost:3000/api/drops';
try {
// Mock request for now
await fetch(`${WEBSITE_API}/${id}`, {
method: 'DELETE',
}).catch(() => {});
} catch (e) {}
await message.reply({
embeds: [createEmbed({
title: 'πŸ—‘οΈ Drop Deleted',
description: `Successfully deleted Drop **#${id}** (${drop.title}) from the website backend.`,
color: Colors.SUCCESS
})]
});
} catch (err) {
console.error('[Delete Drop Error]', err);
await message.reply({ content: `❌ Error deleting drop: ${err.message}` });
}
}
};