mirror of
https://github.com/aydenjahola/discord-multipurpose-bot.git
synced 2024-11-22 16:55:55 +00:00
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
|
const { SlashCommandBuilder } = require("discord.js");
|
||
|
const SpyfallGame = require("../../models/SpyfallGame");
|
||
|
|
||
|
module.exports = {
|
||
|
data: new SlashCommandBuilder()
|
||
|
.setName("stopspyfall")
|
||
|
.setDescription("Stop the current Spyfall game in this server."),
|
||
|
|
||
|
async execute(interaction) {
|
||
|
try {
|
||
|
const guildId = interaction.guild.id;
|
||
|
|
||
|
const ongoingGame = await SpyfallGame.findOne({
|
||
|
guildId: guildId,
|
||
|
status: "ongoing",
|
||
|
});
|
||
|
|
||
|
if (!ongoingGame) {
|
||
|
return interaction.reply({
|
||
|
content: "No Spyfall game is currently in progress in this server!",
|
||
|
ephemeral: true,
|
||
|
});
|
||
|
}
|
||
|
|
||
|
ongoingGame.status = "ended";
|
||
|
await ongoingGame.save();
|
||
|
|
||
|
await interaction.reply("The Spyfall game has been stopped!");
|
||
|
} catch (error) {
|
||
|
console.error("Error stopping the game:", error);
|
||
|
await interaction.reply({
|
||
|
content:
|
||
|
"There was an error trying to stop the game. Please try again later.",
|
||
|
ephemeral: true,
|
||
|
});
|
||
|
}
|
||
|
},
|
||
|
};
|