-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathend.js
40 lines (38 loc) · 1.01 KB
/
end.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const { SlashCommandBuilder } = require("discord.js");
const {
cleanupFiles,
clearInactiveTimer,
deletePtnFile,
getGameData,
getLink,
isGameOngoing,
renameChannel,
sendMessage,
setDeleteTimer,
} = require("../util");
module.exports = {
data: new SlashCommandBuilder()
.setName("end")
.setDescription("Cancel the current game."),
async execute(interaction) {
if (!isGameOngoing(interaction)) {
return sendMessage(
interaction,
"There is no ongoing game in this channel.",
true
);
}
const gameData = getGameData(interaction);
let message = "The game in this channel has been removed.";
if (gameData.hl) {
message +=
"\nHere's a link to the unfinished game:\n" + getLink(gameData.gameId);
}
cleanupFiles(interaction.channel.id);
deletePtnFile(gameData);
await sendMessage(interaction, message);
clearInactiveTimer(interaction);
setDeleteTimer(interaction);
return renameChannel(interaction, false);
},
};