Debug: Defer all debug replies and lock clear_cards in production
This commit is contained in:
@@ -2,6 +2,7 @@ const { SlashCommandBuilder, ComponentType, ActionRowBuilder, ButtonBuilder, But
|
|||||||
const { customAlphabet } = require("nanoid");
|
const { customAlphabet } = require("nanoid");
|
||||||
const { Card, User } = require("../models");
|
const { Card, User } = require("../models");
|
||||||
const { UserUtils, CardUtils, GeneralUtils } = require("../util");
|
const { UserUtils, CardUtils, GeneralUtils } = require("../util");
|
||||||
|
require('dotenv').config();
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
@@ -43,6 +44,7 @@ module.exports = {
|
|||||||
),
|
),
|
||||||
permissionLevel: 2,
|
permissionLevel: 2,
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
|
await interaction.deferReply();
|
||||||
const identifier = CardUtils.generateIdentifier();
|
const identifier = CardUtils.generateIdentifier();
|
||||||
let user = await UserUtils.getUserByDiscordId(interaction.member.id);
|
let user = await UserUtils.getUserByDiscordId(interaction.member.id);
|
||||||
let extUser;
|
let extUser;
|
||||||
@@ -53,7 +55,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
switch (interaction.options.getString("feature")) {
|
switch (interaction.options.getString("feature")) {
|
||||||
case "ping":
|
case "ping":
|
||||||
interaction.reply({
|
interaction.editReply({
|
||||||
content: "Pong!",
|
content: "Pong!",
|
||||||
ephemeral: true
|
ephemeral: true
|
||||||
});
|
});
|
||||||
@@ -65,17 +67,23 @@ module.exports = {
|
|||||||
console.log(nanoid());
|
console.log(nanoid());
|
||||||
ids.push(nanoid());
|
ids.push(nanoid());
|
||||||
}
|
}
|
||||||
interaction.reply({
|
interaction.editReply({
|
||||||
content: `${JSON.stringify(ids)}`,
|
content: `${JSON.stringify(ids)}`,
|
||||||
ephemeral: false
|
ephemeral: false
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "clear_cards":
|
case "clear_cards":
|
||||||
|
if (process.env.NODE_ENV === "production") {
|
||||||
|
interaction.editReply({
|
||||||
|
content: "This command is disabled in production."
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
const cards = await Card.findAll();
|
const cards = await Card.findAll();
|
||||||
for (let i = 0; i < cards.length; i++) {
|
for (let i = 0; i < cards.length; i++) {
|
||||||
await cards[i].destroy();
|
await cards[i].destroy();
|
||||||
}
|
}
|
||||||
interaction.reply({
|
interaction.editReply({
|
||||||
content: `Cleared ${cards.length} cards`,
|
content: `Cleared ${cards.length} cards`,
|
||||||
ephemeral: false
|
ephemeral: false
|
||||||
});
|
});
|
||||||
@@ -84,14 +92,14 @@ module.exports = {
|
|||||||
const timeouts = await UserUtils.getCooldowns(user);
|
const timeouts = await UserUtils.getCooldowns(user);
|
||||||
console.log(`UserTimeouts: ${JSON.stringify(timeouts)}`);
|
console.log(`UserTimeouts: ${JSON.stringify(timeouts)}`);
|
||||||
let timeoutInMinutes = 0;
|
let timeoutInMinutes = 0;
|
||||||
interaction.reply({
|
interaction.editReply({
|
||||||
content: `\`\`\`${JSON.stringify(timeouts, null, 2)}\`\`\` `,
|
content: `\`\`\`${JSON.stringify(timeouts, null, 2)}\`\`\` `,
|
||||||
ephemeral: false
|
ephemeral: false
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "bot":
|
case "bot":
|
||||||
let botProperties = await GeneralUtils.getBotProperty(null);
|
let botProperties = await GeneralUtils.getBotProperty(null);
|
||||||
interaction.reply({
|
interaction.editReply({
|
||||||
content: `\`\`\`${JSON.stringify(botProperties, null, 2)}\`\`\` `,
|
content: `\`\`\`${JSON.stringify(botProperties, null, 2)}\`\`\` `,
|
||||||
ephemeral: false
|
ephemeral: false
|
||||||
});
|
});
|
||||||
@@ -100,14 +108,14 @@ module.exports = {
|
|||||||
await UserUtils.setCooldown(extUser, "pull", 1);
|
await UserUtils.setCooldown(extUser, "pull", 1);
|
||||||
await UserUtils.setCooldown(extUser, "drop", 1);
|
await UserUtils.setCooldown(extUser, "drop", 1);
|
||||||
await UserUtils.setCooldown(extUser, "daily", 1);
|
await UserUtils.setCooldown(extUser, "daily", 1);
|
||||||
interaction.reply({
|
interaction.editReply({
|
||||||
content: `Reset cooldowns for <@${extUser.discordId}>`,
|
content: `Reset cooldowns for <@${extUser.discordId}>`,
|
||||||
ephemeral: false
|
ephemeral: false
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "add_xp":
|
case "add_xp":
|
||||||
await extUser.addExperience(interaction.options.getString("value"))
|
await extUser.addExperience(interaction.options.getString("value"))
|
||||||
interaction.reply({
|
interaction.editReply({
|
||||||
content: `Added ${interaction.options.getString("value")} XP to <@${extUser.discordId}>`,
|
content: `Added ${interaction.options.getString("value")} XP to <@${extUser.discordId}>`,
|
||||||
ephemeral: false
|
ephemeral: false
|
||||||
});
|
});
|
||||||
@@ -115,13 +123,13 @@ module.exports = {
|
|||||||
case "toggle_maintenance":
|
case "toggle_maintenance":
|
||||||
let maintenance = await GeneralUtils.getBotProperty("maintenance");
|
let maintenance = await GeneralUtils.getBotProperty("maintenance");
|
||||||
await GeneralUtils.setBotProperty("maintenance", !maintenance);
|
await GeneralUtils.setBotProperty("maintenance", !maintenance);
|
||||||
interaction.reply({
|
interaction.editReply({
|
||||||
content: `Maintenance mode is now ${!maintenance}`,
|
content: `Maintenance mode is now ${!maintenance}`,
|
||||||
ephemeral: false
|
ephemeral: false
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
interaction.reply({
|
interaction.editReply({
|
||||||
content: `Your permission level is ${await UserUtils.getPermissionLevel(interaction.member)}`,
|
content: `Your permission level is ${await UserUtils.getPermissionLevel(interaction.member)}`,
|
||||||
ephemeral: false
|
ephemeral: false
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user