-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhistory.js
26 lines (25 loc) · 831 Bytes
/
history.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
const { SlashCommandBuilder } = require("discord.js");
const { getHistoryFromFile, sendMessage } = require("../util");
module.exports = {
data: new SlashCommandBuilder()
.setName("history")
.setDescription(
"Get a list of finished games and their IDs. Use a page number to see older games."
)
.addIntegerOption((option) =>
option.setName("page").setDescription("Page number")
),
async execute(interaction) {
try {
const page = interaction.options.getInteger("page") || 1;
let historyData = getHistoryFromFile(page);
if (historyData) {
return sendMessage(interaction, "```\n" + historyData + "\n```", true);
} else {
return sendMessage(interaction, "Not a valid page number", true);
}
} catch (err) {
console.error(err);
}
},
};