refactor(events/channel): adding the tsconfig + eslint correction
This commit is contained in:
parent
6884b265c2
commit
5db6c9ee3e
3 changed files with 11 additions and 13 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
import { Events, AuditLogEvent, TextChannel, EmbedBuilder, Channel } from 'discord.js';
|
import { Events, AuditLogEvent, TextChannel, EmbedBuilder, Channel } from 'discord.js';
|
||||||
import { prisma } from '../../lib/prisma';
|
import { prisma } from '../../lib/prisma';
|
||||||
import { Guild as GuildPrisma } from '@prisma/client';
|
import { Guild as GuildPrisma } from '@prisma/client';
|
||||||
import { isWhitelisted } from '../../lib/perm.ts';
|
import { isWhitelisted } from '@lib/perm';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: Events.ChannelCreate,
|
name: Events.ChannelCreate,
|
||||||
|
|
@ -21,8 +21,7 @@ export default {
|
||||||
id: channel.guild.id,
|
id: channel.guild.id,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!guildData) return;
|
if (!(await isWhitelisted(executor.id, channel.guild.id))) {
|
||||||
if (!isWhitelisted(executor.id, channel.guild.id)) {
|
|
||||||
await channel.delete(`Unauthorized channel creation by ${executor.tag}`);
|
await channel.delete(`Unauthorized channel creation by ${executor.tag}`);
|
||||||
const member = await channel.guild.members.fetch(executor.id).catch(() => null);
|
const member = await channel.guild.members.fetch(executor.id).catch(() => null);
|
||||||
if (member) {
|
if (member) {
|
||||||
|
|
@ -44,7 +43,7 @@ export default {
|
||||||
.setFooter({
|
.setFooter({
|
||||||
text: guildData.footer,
|
text: guildData.footer,
|
||||||
});
|
});
|
||||||
(logChannel as TextChannel).send({
|
await (logChannel as TextChannel).send({
|
||||||
embeds: [embed],
|
embeds: [embed],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -62,14 +61,14 @@ export default {
|
||||||
.setFooter({
|
.setFooter({
|
||||||
text: guildData.footer,
|
text: guildData.footer,
|
||||||
});
|
});
|
||||||
(logChannel as TextChannel).send({
|
await (logChannel as TextChannel).send({
|
||||||
embeds: [embed],
|
embeds: [embed],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(`⚠️ | ChannelCreate protection error: ${err}`);
|
console.error(`⚠️ | ChannelCreate protection error: ${err as Error}`);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { Events, AuditLogEvent, TextChannel, EmbedBuilder, Channel } from 'discord.js';
|
import { Events, AuditLogEvent, TextChannel, EmbedBuilder, Channel } from 'discord.js';
|
||||||
import { prisma } from '../../lib/prisma';
|
import { prisma } from '../../lib/prisma';
|
||||||
import { Guild as GuildPrisma } from '@prisma/client';
|
import { Guild as GuildPrisma } from '@prisma/client';
|
||||||
import { isWhitelisted } from '../../lib/perm.ts';
|
import { isWhitelisted } from '@lib/perm';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: Events.ChannelDelete,
|
name: Events.ChannelDelete,
|
||||||
|
|
@ -21,7 +21,6 @@ export default {
|
||||||
id: channel.guild.id,
|
id: channel.guild.id,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!guildData) return;
|
|
||||||
if (!(await isWhitelisted(executor.id, channel.guild.id))) {
|
if (!(await isWhitelisted(executor.id, channel.guild.id))) {
|
||||||
const member = await channel.guild.members.fetch(executor.id).catch(() => null);
|
const member = await channel.guild.members.fetch(executor.id).catch(() => null);
|
||||||
if (member) {
|
if (member) {
|
||||||
|
|
@ -46,7 +45,7 @@ export default {
|
||||||
.setFooter({
|
.setFooter({
|
||||||
text: guildData.footer,
|
text: guildData.footer,
|
||||||
});
|
});
|
||||||
(logChannel as TextChannel).send({
|
await (logChannel).send({
|
||||||
embeds: [embed],
|
embeds: [embed],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -64,14 +63,14 @@ export default {
|
||||||
.setFooter({
|
.setFooter({
|
||||||
text: guildData.footer,
|
text: guildData.footer,
|
||||||
});
|
});
|
||||||
(logChannel as TextChannel).send({
|
await (logChannel).send({
|
||||||
embeds: [embed],
|
embeds: [embed],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(`⚠️ | ChannelDelete protection error: ${err}`);
|
console.error(`⚠️ | ChannelDelete protection error: ${err as Error}`);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export default {
|
||||||
limit: 5,
|
limit: 5,
|
||||||
});
|
});
|
||||||
const entry = [...logs.entries.values()]
|
const entry = [...logs.entries.values()]
|
||||||
.filter(e => (e.target as GuildChannel)?.id === newChannel.id)
|
.filter(e => (e.target as GuildChannel).id === newChannel.id)
|
||||||
.sort((a, b) => b.createdTimestamp - a.createdTimestamp)[0];
|
.sort((a, b) => b.createdTimestamp - a.createdTimestamp)[0];
|
||||||
const executor = entry?.executor;
|
const executor = entry?.executor;
|
||||||
const guildData: GuildPrisma | null = await prisma.guild.findUnique({
|
const guildData: GuildPrisma | null = await prisma.guild.findUnique({
|
||||||
|
|
@ -78,7 +78,7 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(`⚠️ | ChannelUpdate log error: ${err}`);
|
console.error(`⚠️ | ChannelUpdate log error: ${err as Error}`);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue