Small fix
This commit is contained in:
@@ -1,18 +1,15 @@
|
||||
const { Events, MessageFlags } = require('discord.js');
|
||||
const { isCommandAllowed } = require('../services/permissions');
|
||||
const {Events, MessageFlags} = require('discord.js');
|
||||
const {isCommandAllowed} = require('../services/permissions');
|
||||
|
||||
module.exports = {
|
||||
name: Events.InteractionCreate,
|
||||
async execute(interaction) {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
const command = interaction.client.commands.get(interaction.commandName);
|
||||
|
||||
if (!command) {
|
||||
console.error(`No command matching ${interaction.commandName} was found.`);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const allowed = await isCommandAllowed({
|
||||
guildId: interaction.guildId,
|
||||
@@ -21,7 +18,6 @@ module.exports = {
|
||||
commandName: interaction.commandName,
|
||||
permissionGroup: command.permissionGroup,
|
||||
});
|
||||
|
||||
if (!allowed) {
|
||||
await interaction.reply({
|
||||
content: 'You do not have permission to use this command.',
|
||||
@@ -29,14 +25,19 @@ module.exports = {
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
await command.execute(interaction);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
if (interaction.replied || interaction.deferred) {
|
||||
await interaction.followUp({ content: 'There was an error while executing this command!', flags: MessageFlags.Ephemeral });
|
||||
await interaction.followUp({
|
||||
content: 'There was an error while executing this command!',
|
||||
flags: MessageFlags.Ephemeral
|
||||
});
|
||||
} else {
|
||||
await interaction.reply({ content: 'There was an error while executing this command!', flags: MessageFlags.Ephemeral });
|
||||
await interaction.reply({
|
||||
content: 'There was an error while executing this command!',
|
||||
flags: MessageFlags.Ephemeral
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -10,8 +10,6 @@ module.exports = {
|
||||
const tempBanCollection = db.collection('tempban');
|
||||
const scheduledBanIds = new Set();
|
||||
let pollingInterval = null;
|
||||
|
||||
// 2) Define a function to schedule unbans
|
||||
async function scheduleUnban(banData) {
|
||||
const banId = banData?._id?.toString();
|
||||
if (banId && scheduledBanIds.has(banId)) {
|
||||
@@ -54,7 +52,6 @@ module.exports = {
|
||||
if (pollingInterval) {
|
||||
return;
|
||||
}
|
||||
console.warn('Change streams unavailable; falling back to polling for temp bans.');
|
||||
pollingInterval = setInterval(() => {
|
||||
loadAndScheduleBans().catch((err) => {
|
||||
console.error('Error polling temp bans:', err);
|
||||
|
||||
Reference in New Issue
Block a user