2024-12-28 14:04:25 +00:00
|
|
|
|
const { SlashCommandBuilder, MessageFlags, EmbedBuilder } = require('discord.js');
|
|
|
|
|
const { Tournament } = require("../../data_objects/tournament.js");
|
|
|
|
|
const { tetrioRanks } = require("../../data_objects/tetrio_ranks.js");
|
|
|
|
|
const { updateTournamentsJSON } = require("../../utils.js");
|
|
|
|
|
const { tournaments, blacklist, whitelist } = require("../../index.js");
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
data: new SlashCommandBuilder()
|
|
|
|
|
.setName('delete_event')
|
|
|
|
|
.setDescription('Удалить событие и всё связанное с ним')
|
|
|
|
|
.addStringOption(option =>
|
|
|
|
|
option.setName('key')
|
|
|
|
|
.setDescription('Время создания события')
|
|
|
|
|
.setRequired(true)),
|
|
|
|
|
async execute(interaction) {
|
|
|
|
|
const t = tournaments.get(interaction.options.getString('key'));
|
|
|
|
|
try{
|
|
|
|
|
await interaction.guild.roles.delete(t.participant_role, 'Информация о турнире удалена');
|
|
|
|
|
await interaction.guild.roles.delete(t.checked_in_role, 'Информация о турнире удалена');
|
2025-01-09 17:28:12 +00:00
|
|
|
|
const msg_channel = await interaction.client.channels.fetch(t.channelID);
|
|
|
|
|
const msg = await msg_channel.messages.fetch(t.messageID);
|
2024-12-28 14:04:25 +00:00
|
|
|
|
msg.delete();
|
|
|
|
|
interaction.reply({ content: `Готово`, flags: MessageFlags.Ephemeral });
|
|
|
|
|
}catch(e){
|
|
|
|
|
interaction.reply({ content: `Не всё прошло гладко, но турнир из бота был удален\n\`${e}\``, flags: MessageFlags.Ephemeral });
|
|
|
|
|
}
|
|
|
|
|
tournaments.delete(interaction.options.getString('key'));
|
|
|
|
|
updateTournamentsJSON();
|
|
|
|
|
},
|
|
|
|
|
};
|