| const { createEmbed } = require('../utils/embeds'); |
| const { Colors } = require('../config'); |
| const { stmts } = require('../database'); |
| const fetch = require('node-fetch'); |
|
|
| |
| |
| |
| 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 { |
| |
| await stmts.deleteWebDrop(id); |
|
|
| |
| const WEBSITE_API = process.env.WEBSITE_API_URL || 'http://localhost:3000/api/drops'; |
| |
| try { |
| |
| 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}` }); |
| } |
| } |
| }; |
|
|