discord-multipurpose-bot/commands/events/leaveEvent.js
Ayden cb5a906850
Some checks are pending
Docker / build (push) Waiting to run
Feat/Add Music Commands (#1)
* add simple music functionality

* update workflow

* update Dockerfile

* update Dockerfile

* update Dockerfile

* update Dockerfile

* add few more music commands

* add lyrics command

* update lyrics command

* add loop, and add categories to all commands

* change discord status

* seperate distube and change startup console theme

* Update README

* UPDATE LICENSE file

* fix docker compose image, add better error handling for distube and update tagging workflow

* switch to node-alpine image for docker

* switch to node-alpine image for docker

* update ascii

* music commands imporvements, implement live lyrics, some guards and bot leaving on empty

* use ffmpeg package rather than ffmpeg-static
2025-09-21 01:26:18 +01:00

73 lines
2 KiB
JavaScript

const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const Event = require("../../models/Event");
const Participant = require("../../models/Participant");
module.exports = {
data: new SlashCommandBuilder()
.setName("leaveevent")
.setDescription("Leave an event.")
.addStringOption((option) =>
option
.setName("event_name")
.setDescription("Name of the event to leave")
.setRequired(true)
),
category: "Events",
async execute(interaction) {
const eventName = interaction.options.getString("event_name");
const event = await Event.findOne({ name: eventName });
if (!event) {
return await interaction.reply({
content: `Event "${eventName}" not found.`,
ephemeral: false,
});
}
const participant = await Participant.findOne({
userId: interaction.user.id,
});
if (!participant) {
return await interaction.reply({
content: `You are not a participant of this event.`,
ephemeral: false,
});
}
event.participants.pull(participant._id);
await event.save();
const isInOtherEvents = await Event.exists({
participants: participant._id,
});
if (!isInOtherEvents) {
await Participant.deleteOne({ userId: interaction.user.id });
}
const embed = new EmbedBuilder()
.setTitle(`Left Event: ${event.name}`)
.setColor("#e74c3c")
.addFields(
{
name: "Category",
value: event.category || "Not specified",
inline: true,
},
{ name: "Location", value: event.location || "Virtual", inline: true },
{
name: "Participants Remaining",
value: String(event.participants.length),
inline: true,
}
)
.setFooter({
text: `Left by ${interaction.user.username}`,
iconURL: interaction.user.displayAvatarURL(),
})
.setTimestamp();
await interaction.reply({ embeds: [embed] });
},
};