Skip to content

Commit d2511b6

Browse files
authored
Updated unban.js
1 parent 20b6a6a commit d2511b6

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/commands/moderation/unban.js

+19-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const fs = require("fs");
99
const path = require("path");
1010

1111
const logChannelsPath = path.join(__dirname, "../logChannels.json");
12+
const logsFilePath = path.join(__dirname, "../modlogs.json");
1213

1314
module.exports = {
1415
/**
@@ -80,8 +81,25 @@ module.exports = {
8081
console.error("Log channel not found.");
8182
}
8283
}
84+
85+
let modLogs = {};
86+
if (fs.existsSync(logsFilePath)) {
87+
const data = fs.readFileSync(logsFilePath);
88+
modLogs = JSON.parse(data);
89+
}
90+
91+
if (!modLogs[targetUser.id]) modLogs[targetUser.id] = [];
92+
93+
modLogs[targetUser.id].push({
94+
type: "Unban",
95+
reason: reason,
96+
moderator: interaction.user.id,
97+
timestamp: Math.floor(Date.now() / 1000),
98+
});
99+
100+
fs.writeFileSync(logsFilePath, JSON.stringify(modLogs, null, 2));
83101
} catch (error) {
84-
console.error("Error unbanning user:", error);
102+
console.error(`Error unbanning user:, ${error}`);
85103
await interaction.editReply("An error occurred while trying to unban the user.");
86104
}
87105
},

0 commit comments

Comments
 (0)