-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathredraw.js
35 lines (32 loc) · 905 Bytes
/
redraw.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
const { SlashCommandBuilder } = require("discord.js");
const {
clearInactiveTimer,
drawBoard,
getGameData,
getTheme,
getTurnMessage,
isGameOngoing,
sendMessage,
sendPngToDiscord,
setInactiveTimer,
} = require("../util");
module.exports = {
data: new SlashCommandBuilder()
.setName("redraw")
.setDescription("Re-send the last board of 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);
const canvas = drawBoard(gameData, getTheme(interaction));
const message = getTurnMessage(gameData, canvas);
clearInactiveTimer(interaction);
setInactiveTimer(interaction, gameData, canvas);
return sendPngToDiscord(interaction, canvas, message);
},
};