Compare commits
No commits in common. "dde334bdfa27b661f4bacd09d0b68f3426d2eea6" and "96dabb6693b87a623f2c8768aaf2a0e759b7d2df" have entirely different histories.
dde334bdfa
...
96dabb6693
9 changed files with 16 additions and 362 deletions
|
|
@ -42,11 +42,6 @@ export default {
|
|||
|
||||
const category = categoryOption as CategoryChannel;
|
||||
|
||||
await interaction.reply({
|
||||
content: `${emoji.answer.loading} | Starting the deletion of **${category.name}**.`,
|
||||
flags: MessageFlags.Ephemeral,
|
||||
});
|
||||
|
||||
try {
|
||||
for (const channel of category.children.cache.values()) {
|
||||
await channel.delete(
|
||||
|
|
@ -58,12 +53,11 @@ export default {
|
|||
`Deleted ${category.name} (requested by ${interaction.user.username})`,
|
||||
);
|
||||
|
||||
if (interaction.channel) {
|
||||
await interaction.editReply({
|
||||
await interaction.reply({
|
||||
content: `${emoji.answer.yes} | Deleted category **${category.name}** and its channels.`,
|
||||
flags: MessageFlags.Ephemeral,
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (err: unknown) {
|
||||
log.error(err, 'Cannot delete category or its channels');
|
||||
await interaction.reply({
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import {
|
|||
import emoji from '../../../assets/emoji.json' assert { type: 'json' };
|
||||
import { Guild as GuildPrisma, User as UserPrisma } from '@prisma/client';
|
||||
import { log } from '@lib/log';
|
||||
import { isOwner } from '@lib/perm';
|
||||
import { isOwner } from '@lib/perm.js';
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
|
|
@ -32,6 +32,10 @@ export default {
|
|||
name: 'Show',
|
||||
value: 'logs_show',
|
||||
},
|
||||
{
|
||||
name: 'Auto-configuration',
|
||||
value: 'logs_auto',
|
||||
},
|
||||
{
|
||||
name: 'Configuration',
|
||||
value: 'logs_config',
|
||||
|
|
@ -139,7 +143,7 @@ export default {
|
|||
}
|
||||
return;
|
||||
}
|
||||
case 'logs_config': {
|
||||
case 'logs_auto': {
|
||||
if (!await isOwner(interaction.user.id)) {
|
||||
await interaction.reply({
|
||||
content: `${emoji.answer.no} | This command is only for owner`,
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ export default {
|
|||
});
|
||||
await new Promise((res) => setTimeout(res, 1000));
|
||||
}
|
||||
catch {
|
||||
catch (err) {
|
||||
log.info(`Not able to fetch user ${buyer.id}`);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,64 +0,0 @@
|
|||
import {
|
||||
AuditLogEvent,
|
||||
Channel,
|
||||
EmbedBuilder,
|
||||
Events,
|
||||
Guild,
|
||||
GuildAuditLogs,
|
||||
GuildBan,
|
||||
User,
|
||||
} from 'discord.js';
|
||||
import { Guild as GuildPrisma } from '@prisma/client';
|
||||
import { prisma } from '@lib/prisma';
|
||||
|
||||
export default {
|
||||
name: Events.GuildBanAdd,
|
||||
async execute(ban: GuildBan) {
|
||||
const guild: Guild = ban.guild;
|
||||
const banned_user: User = ban.user;
|
||||
const fetchedLogs: GuildAuditLogs<AuditLogEvent.MemberBanAdd> = await guild.fetchAuditLogs({
|
||||
limit: 5,
|
||||
type: AuditLogEvent.MemberBanAdd,
|
||||
});
|
||||
const banLog = fetchedLogs.entries.find(
|
||||
(entry) => entry.target?.id === banned_user.id,
|
||||
);
|
||||
const executor: string = banLog.executor.username ?? 'Unknown executor';
|
||||
const reason: string = ban.reason ?? banLog.reason ?? 'No reason provided';
|
||||
const guildData: GuildPrisma = await prisma.guild.findUnique({
|
||||
where: {
|
||||
id: guild.id,
|
||||
},
|
||||
});
|
||||
|
||||
const toSend: EmbedBuilder = new EmbedBuilder()
|
||||
.setTitle('🔨 | Member banned')
|
||||
.setAuthor({
|
||||
name: `${banned_user.username} (${banned_user.id})`,
|
||||
iconURL: banned_user.displayAvatarURL({
|
||||
size: 2048,
|
||||
extension: 'png',
|
||||
}),
|
||||
})
|
||||
.setColor(guildData.color)
|
||||
.setFooter({
|
||||
text: guildData.footer,
|
||||
})
|
||||
.setTimestamp().setDescription(`
|
||||
**Banned by:**
|
||||
${executor}
|
||||
**Reason:**
|
||||
${reason}
|
||||
`);
|
||||
if (guildData.logMod) {
|
||||
const logChannel: Channel | null = await guild.client.channels.fetch(
|
||||
guildData.logMod,
|
||||
);
|
||||
if (logChannel) {
|
||||
logChannel.send({
|
||||
embeds: [toSend],
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
@ -1,98 +0,0 @@
|
|||
import {
|
||||
AuditLogEvent,
|
||||
Channel,
|
||||
EmbedBuilder,
|
||||
Events,
|
||||
Guild,
|
||||
GuildAuditLogs,
|
||||
GuildBan,
|
||||
User,
|
||||
} from 'discord.js';
|
||||
import { Guild as GuildPrisma } from '@prisma/client';
|
||||
import { prisma } from '@lib/prisma';
|
||||
|
||||
export default {
|
||||
name: Events.GuildBanRemove,
|
||||
async execute(ban: GuildBan) {
|
||||
const guild: Guild = ban.guild;
|
||||
const banned_user: User = ban.user;
|
||||
const banFetchLog: GuildAuditLogs<AuditLogEvent.MemberBanAdd> =
|
||||
await guild.fetchAuditLogs({
|
||||
limit: 99,
|
||||
type: AuditLogEvent.MemberBanAdd,
|
||||
});
|
||||
const banLog = banFetchLog.entries.find(
|
||||
(entry) => entry.target?.id === banned_user.id,
|
||||
);
|
||||
const unbanFetchLog: GuildAuditLogs<AuditLogEvent.MemberBanRemove> =
|
||||
await guild.fetchAuditLogs({
|
||||
limit: 99,
|
||||
type: AuditLogEvent.MemberBanRemove,
|
||||
});
|
||||
const unbanLog = unbanFetchLog.entries.find(
|
||||
(entry) => entry.target?.id === banned_user.id,
|
||||
);
|
||||
const executor: string = banLog.executor.username ?? 'Unknown executor';
|
||||
const reason: string = ban.reason ?? banLog.reason ?? 'No reason provided';
|
||||
const bannedAt: number | undefined = banLog?.createdTimestamp;
|
||||
const unbannedAt: number | undefined = unbanLog?.createdTimestamp;
|
||||
let durationFormatted: string | null = null;
|
||||
if (unbannedAt && bannedAt) {
|
||||
const durationMs: number = unbannedAt - bannedAt;
|
||||
const durationTotalSeconds: number = Math.max(0, Math.floor(durationMs / 1000));
|
||||
const durationHours: number = Math.floor(durationTotalSeconds / 3600);
|
||||
const durationMinutes: number = Math.floor((durationTotalSeconds % 3600) / 60);
|
||||
const durationSeconds: number = durationTotalSeconds % 60;
|
||||
const durationParts: string[] = [];
|
||||
if (durationHours > 0) {
|
||||
durationParts.push(`${durationHours}h`);
|
||||
}
|
||||
if (durationMinutes > 0) {
|
||||
durationParts.push(`${durationMinutes}m`);
|
||||
}
|
||||
if (durationSeconds > 0 || durationParts.length === 0) {
|
||||
durationParts.push(`${durationSeconds}s`);
|
||||
}
|
||||
durationFormatted = durationParts.join(' ');
|
||||
}
|
||||
const guildData: GuildPrisma = await prisma.guild.findUnique({
|
||||
where: {
|
||||
id: guild.id,
|
||||
},
|
||||
});
|
||||
|
||||
const toSend: EmbedBuilder = new EmbedBuilder()
|
||||
.setTitle('🔨 | Member Unbanned')
|
||||
.setAuthor({
|
||||
name: `${banned_user.username} (${banned_user.id})`,
|
||||
iconURL: banned_user.displayAvatarURL({
|
||||
size: 2048,
|
||||
extension: 'png',
|
||||
}),
|
||||
})
|
||||
.setColor(guildData.color)
|
||||
.setFooter({
|
||||
text: guildData.footer,
|
||||
})
|
||||
.setTimestamp().setDescription(`
|
||||
**Banned by:**
|
||||
${executor}
|
||||
**Banned the:**
|
||||
${bannedAt ? `<t:${Math.floor(bannedAt / 1000)}:D> (<t:${Math.floor(bannedAt / 1000)}:R>)` : 'No date found'}
|
||||
**Ban Duration:**
|
||||
${durationFormatted ?? 'Cannot calculate the ban duration'}
|
||||
**Reason:**
|
||||
${reason}
|
||||
`);
|
||||
if (guildData.logMod) {
|
||||
const logChannel: Channel | null = await guild.client.channels.fetch(
|
||||
guildData.logMod,
|
||||
);
|
||||
if (logChannel) {
|
||||
logChannel.send({
|
||||
embeds: [toSend],
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
import { Channel, EmbedBuilder, Events, GuildMember } from 'discord.js';
|
||||
import { Guild as GuildPrisma } from '@prisma/client';
|
||||
import { prisma } from '@lib/prisma';
|
||||
import { placeholder } from '@lib/placeholder';
|
||||
|
||||
export default {
|
||||
name: Events.GuildMemberAdd,
|
||||
async execute(member: GuildMember) {
|
||||
const memberId: string = member.id;
|
||||
const guildId: string = member.guild.id;
|
||||
const guildData: GuildPrisma = await prisma.guild.findUnique({
|
||||
where: {
|
||||
id: guildId,
|
||||
},
|
||||
});
|
||||
if (guildData.joinEnabled) {
|
||||
const fetchedChannel: Channel | null = await member.client.channels.fetch(guildData.joinChannel as string);
|
||||
if (fetchedChannel) {
|
||||
fetchedChannel.send({
|
||||
content: placeholder(guildData.joinMessage, member),
|
||||
});
|
||||
}
|
||||
}
|
||||
if (guildData.logMember) {
|
||||
const toSend: EmbedBuilder = new EmbedBuilder()
|
||||
.setTitle('🛬 | Member just joined')
|
||||
.setAuthor({
|
||||
name: `${member.user.username} (${member.user.id})`,
|
||||
iconURL: member.displayAvatarURL({
|
||||
size: 2048,
|
||||
extension: 'png',
|
||||
}),
|
||||
})
|
||||
.setColor(guildData.color)
|
||||
.setFooter({
|
||||
text: guildData.footer,
|
||||
})
|
||||
.setTimestamp()
|
||||
.setDescription(`
|
||||
**Acount Creation:**
|
||||
<t:${Math.floor(member.user.createdTimestamp / 1000)}:D> (<t:${Math.floor(member.user.createdTimestamp / 1000)}:R>)
|
||||
**JoinDate:**
|
||||
<t:${Math.floor(member.joinedTimestamp / 1000)}:D> (<t:${Math.floor(member.joinedTimestamp / 1000)}:R>)
|
||||
`);
|
||||
const fetchedChannel: Channel | null = await member.client.channels.fetch(guildData.logMember as string);
|
||||
if (fetchedChannel) {
|
||||
fetchedChannel.send({
|
||||
embeds: [toSend],
|
||||
});
|
||||
}
|
||||
}
|
||||
await prisma.user.upsert({
|
||||
where: {
|
||||
id: memberId,
|
||||
},
|
||||
update: {},
|
||||
create: {
|
||||
id: memberId,
|
||||
},
|
||||
});
|
||||
await prisma.guildUser.upsert({
|
||||
where: {
|
||||
userId_guildId: {
|
||||
userId: memberId,
|
||||
guildId: guildId,
|
||||
},
|
||||
},
|
||||
update: {},
|
||||
create: {
|
||||
user: {
|
||||
connect:
|
||||
{
|
||||
id: memberId,
|
||||
},
|
||||
},
|
||||
guild: {
|
||||
connect: {
|
||||
id: guildId,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
import { Channel, EmbedBuilder, Events, GuildMember } from 'discord.js';
|
||||
import { Guild as GuildPrisma } from '@prisma/client';
|
||||
import { prisma } from '@lib/prisma';
|
||||
import { placeholder } from '@lib/placeholder';
|
||||
import { getUserRoles } from '@lib/roles.js';
|
||||
import { client } from '@lib/client.js';
|
||||
|
||||
export default {
|
||||
name: Events.GuildMemberRemove,
|
||||
async execute(member: GuildMember) {
|
||||
if (member.id === client.user.id) {
|
||||
return ;
|
||||
}
|
||||
const memberId: string = member.id;
|
||||
const guildId: string = member.guild.id;
|
||||
const guildData: GuildPrisma = await prisma.guild.findUnique({
|
||||
where: {
|
||||
id: guildId,
|
||||
},
|
||||
});
|
||||
if (guildData.leaveEnabled) {
|
||||
const fetchedChannel: Channel | null = await member.client.channels.fetch(guildData.leaveChannel as string);
|
||||
if (fetchedChannel) {
|
||||
fetchedChannel.send({
|
||||
content: placeholder(guildData.leaveMessage, member),
|
||||
});
|
||||
}
|
||||
}
|
||||
if (guildData.logMember) {
|
||||
const toSend: EmbedBuilder = new EmbedBuilder()
|
||||
.setTitle('🛫 | Member just left')
|
||||
.setAuthor({
|
||||
name: `${member.user.username} (${member.user.id})`,
|
||||
iconURL: member.displayAvatarURL({
|
||||
size: 2048,
|
||||
extension: 'png',
|
||||
}),
|
||||
})
|
||||
.setColor(guildData.color)
|
||||
.setFooter({
|
||||
text: guildData.footer,
|
||||
})
|
||||
.setTimestamp()
|
||||
.setDescription(`
|
||||
**Roles:**
|
||||
${getUserRoles(member)}
|
||||
|
||||
**Acount Creation:**
|
||||
<t:${Math.floor(member.user.createdTimestamp / 1000)}:D> <t:${Math.floor(member.user.createdTimestamp / 1000)}:R>
|
||||
**JoinDate:**
|
||||
<t:${Math.floor(member.joinedTimestamp / 1000)}:D> <t:${Math.floor(member.joinedTimestamp / 1000)}:R>
|
||||
`);
|
||||
const fetchedChannel: Channel | null = await member.client.channels.fetch(guildData.logMember as string);
|
||||
if (fetchedChannel) {
|
||||
fetchedChannel.send({
|
||||
embeds: [toSend],
|
||||
});
|
||||
}
|
||||
}
|
||||
await prisma.user.upsert({
|
||||
where: {
|
||||
id: memberId,
|
||||
},
|
||||
update: {},
|
||||
create: {
|
||||
id: memberId,
|
||||
},
|
||||
});
|
||||
await prisma.guildUser.upsert({
|
||||
where: {
|
||||
userId_guildId: {
|
||||
userId: memberId,
|
||||
guildId: guildId,
|
||||
},
|
||||
},
|
||||
update: {},
|
||||
create: {
|
||||
user: {
|
||||
connect:
|
||||
{
|
||||
id: memberId,
|
||||
},
|
||||
},
|
||||
guild: {
|
||||
connect: {
|
||||
id: guildId,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
@ -65,7 +65,6 @@ export default {
|
|||
}
|
||||
const toRep = new EmbedBuilder()
|
||||
.setColor(guildData.color)
|
||||
.setTimestamp()
|
||||
.setFooter({
|
||||
text: guildData.footer,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,18 +1,13 @@
|
|||
import { Client, GatewayIntentBits } from 'discord.js';
|
||||
import {
|
||||
Client,
|
||||
GatewayIntentBits,
|
||||
} from 'discord.js';
|
||||
|
||||
export const client: Client = new Client({
|
||||
intents: [
|
||||
GatewayIntentBits.Guilds,
|
||||
GatewayIntentBits.GuildModeration,
|
||||
GatewayIntentBits.GuildMembers,
|
||||
GatewayIntentBits.GuildMessages,
|
||||
GatewayIntentBits.MessageContent,
|
||||
GatewayIntentBits.GuildMessageReactions,
|
||||
GatewayIntentBits.GuildMessageTyping,
|
||||
GatewayIntentBits.GuildVoiceStates,
|
||||
GatewayIntentBits.DirectMessages,
|
||||
GatewayIntentBits.DirectMessageReactions,
|
||||
GatewayIntentBits.AutoModerationConfiguration,
|
||||
GatewayIntentBits.AutoModerationExecution,
|
||||
GatewayIntentBits.GuildMembers,
|
||||
],
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue