fixing eslint
diff --git a/src/events/guildMemberUpdate.ts b/src/events/guildMemberUpdate.ts
index 412ac96..b674060 100644
--- a/src/events/guildMemberUpdate.ts
+++ b/src/events/guildMemberUpdate.ts
@@ -1,60 +1,76 @@
import { AuditLogEvent, GuildAuditLogsEntry, GuildMember } from "discord.js";
import type { NucleusClient } from "../utils/client.js";
import type { LoggerOptions } from "../utils/log.js";
+import { generalException } from "../utils/createTemporaryStorage.js";
export const event = "guildMemberUpdate";
export async function callback(client: NucleusClient, before: GuildMember, after: GuildMember) {
const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = client.logger;
+ if(!before.roles.cache.equals(after.roles.cache)) {
+ const auditLog = (await getAuditLog(after.guild, AuditLogEvent.MemberRoleUpdate))
+ .filter((entry: GuildAuditLogsEntry) => (entry.target as GuildMember)!.id === after.id)[0];
+ if (!auditLog) return;
+ if (client.noLog.includes(`${after.guild.id}${after.id}${auditLog.id}`)) return;
+ generalException(`${after.guild.id}${after.id}${auditLog.id}`);
+ if (auditLog.executor!.id !== client.user!.id) {
+ const rolesAdded = after.roles.cache.filter(role => !before.roles.cache.has(role.id));
+ const rolesRemoved = before.roles.cache.filter(role => !after.roles.cache.has(role.id));
+ let displayName = "Roles Removed";
+ let color = NucleusColors.red;
+ let emoji = "GUILD.ROLES.DELETE";
+ if(rolesAdded.size > 0 && rolesRemoved.size > 0) {displayName = "Roles Changed"; color = NucleusColors.yellow; emoji = "GUILD.ROLES.EDIT";}
+ else if(rolesAdded.size > 0) {displayName = "Roles Added"; color = NucleusColors.green; emoji = "GUILD.ROLES.CREATE";}
+ const removedEntry = rolesRemoved.map(role => role.id);
+ const addedEntry = rolesAdded.map(role => role.id);
+
+ let list = {
+ memberId: entry(after.id, `\`${after.id}\``),
+ name: entry(after.user.id, renderUser(after.user)),
+ };
+
+ if (rolesAdded.size > 0) {
+ list = Object.assign(list, {rolesAdded: entry(addedEntry, addedEntry.map(id => `<@&${id}>`).join(", "))});
+ }
+ if (rolesRemoved.size > 0) {
+ list = Object.assign(list, {rolesRemoved: entry(removedEntry, removedEntry.map(id => `<@&${id}>`).join(", "))});
+ }
+
+ list = Object.assign(list, {
+ changed: entry(Date.now(), renderDelta(Date.now())),
+ changedBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!))
+ });
+
+ let data: LoggerOptions = {
+ meta: {
+ type: "memberUpdate",
+ displayName: displayName,
+ calculateType: "guildMemberUpdate",
+ color: color,
+ emoji: emoji,
+ timestamp: Date.now()
+ },
+ list: {},
+ hidden: {
+ guild: after.guild.id
+ }
+ };
+
+ if(rolesAdded.size > 0) {
+ list = Object.assign(list, {rolesAdded: entry(addedEntry, addedEntry.map(id => `<@&${id}>`).join(", "))});
+ }
+ if(rolesRemoved.size > 0) {
+ list = Object.assign(list, {rolesRemoved: entry(removedEntry, removedEntry.map(id => `<@&${id}>`).join(", "))});
+ }
+ data = Object.assign(data, {list: list});
+ log(data);
+ }
+ }
const auditLog = (await getAuditLog(after.guild, AuditLogEvent.MemberUpdate))
.filter((entry: GuildAuditLogsEntry) => (entry.target as GuildMember)!.id === after.id)[0];
if (!auditLog) return;
if (auditLog.executor!.id === client.user!.id) return;
- if(!before.roles.cache.equals(after.roles.cache)) {
- let rolesAdded = after.roles.cache.filter(role => !before.roles.cache.has(role.id));
- let rolesRemoved = before.roles.cache.filter(role => !after.roles.cache.has(role.id));
- let displayName = "Roles Removed";
- let color = NucleusColors.red;
- let emoji = "GUILD.ROLES.DELETE";
- if(rolesAdded.size > 0 && rolesRemoved.size > 0) {displayName = "Roles Changed"; color = NucleusColors.yellow; emoji = "GUILD.ROLES.EDIT";}
- else if(rolesAdded.size > 0) {displayName = "Roles Added"; color = NucleusColors.green; emoji = "GUILD.ROLES.CREATE";}
- let removedEntry = rolesRemoved.map(role => role.id);
- let addedEntry = rolesAdded.map(role => role.id);
-
- let list = {
- memberId: entry(after.id, `\`${after.id}\``),
- name: entry(after.user.id, renderUser(after.user)),
- changed: entry(Date.now(), renderDelta(Date.now())),
- changedBy: entry(auditLog.executor!.id, renderUser(auditLog.executor!))
- };
-
- let data: LoggerOptions = {
- meta: {
- type: "memberUpdate",
- displayName: displayName,
- calculateType: "guildMemberUpdate",
- color: color,
- emoji: emoji,
- timestamp: Date.now()
- },
- list: {
-
- },
- hidden: {
- guild: after.guild.id
- }
- };
-
- if(rolesAdded.size > 0) {
- list = Object.assign(list, {rolesAdded: entry(addedEntry, addedEntry.map(id => `<@&${id}>`).join(", "))});
- }
- if(rolesRemoved.size > 0) {
- list = Object.assign(list, {rolesRemoved: entry(removedEntry, removedEntry.map(id => `<@&${id}>`).join(", "))});
- }
- data = Object.assign(data, {list: list});
- log(data);
- }
if (before.nickname !== after.nickname) {
await client.database.history.create(
"nickname",
diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts
index 7f8e5d1..44017d7 100644
--- a/src/events/messageCreate.ts
+++ b/src/events/messageCreate.ts
@@ -26,9 +26,9 @@
const content = message.content.toLowerCase() || "";
const config = await client.memory.readGuildInfo(message.guild.id);
if(config.filters.clean.channels.includes(message.channel.id)) {
- let memberRoles = message.member!.roles.cache.map(role => role.id);
- let roleAllow = config.filters.clean.allowed.roles.some(role => memberRoles.includes(role));
- let userAllow = config.filters.clean.allowed.user.includes(message.author.id);
+ const memberRoles = message.member!.roles.cache.map(role => role.id);
+ const roleAllow = config.filters.clean.allowed.roles.some(role => memberRoles.includes(role));
+ const userAllow = config.filters.clean.allowed.user.includes(message.author.id);
if(!roleAllow && !userAllow) return await message.delete();
}
diff --git a/src/events/stickerDelete.ts b/src/events/stickerDelete.ts
index fcfc3a6..87a991f 100644
--- a/src/events/stickerDelete.ts
+++ b/src/events/stickerDelete.ts
@@ -16,7 +16,7 @@
calculateType: "stickerUpdate",
color: NucleusColors.red,
emoji: "GUILD.STICKER.DELETE",
- timestamp: auditLog.createdTimestamp ?? Date.now()
+ timestamp: auditLog.createdTimestamp
},
list: {
stickerId: entry(sticker.id, `\`${sticker.id}\``),