1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-17 16:30:58 -05:00
Daggerbot-TS/src/events/guildMemberAdd.ts

39 lines
2.9 KiB
TypeScript
Raw Normal View History

import Discord from 'discord.js';
2023-04-14 06:47:58 -04:00
import TClient from '../client.js';
2023-08-29 20:21:53 -04:00
import MessageTool from '../helpers/MessageTool.js';
export default {
async run(client:TClient, member:Discord.GuildMember){
2023-03-08 04:04:52 -05:00
if (member.partial || member.guild?.id != client.config.mainServer.id) return;
const index = member.guild.memberCount;
2023-05-23 01:14:17 -04:00
const suffix = (index=>{
2023-03-08 04:04:52 -05:00
const numbers = index.toString().split('').reverse(); // eg 1850 --> [0,5,8,1]
if (numbers[1] === '1') return 'th'; // this is some -teen
else {
if (numbers[0] === '1') return 'st';
else if (numbers[0] === '2') return 'nd';
else if (numbers[0] === '3') return 'rd';
else return 'th';
}
})(index);
let isBot = 'Bot';
if (!member.user.bot) isBot = 'Member';
2023-03-05 05:04:10 -05:00
if (!client.config.botSwitches.logs) return;
(client.channels.resolve(client.config.mainServer.channels.welcome) as Discord.TextChannel).send({embeds: [new client.embed().setColor(client.config.embedColor).setThumbnail(member.user.displayAvatarURL({size: 2048}) || member.user.defaultAvatarURL).setTitle(`Welcome to Daggerwin, ${member.user.username}!`).setFooter({text: `${index}${suffix} member`})]})
2023-03-05 05:04:10 -05:00
const newInvites = await member.guild.invites.fetch();
2023-05-23 01:14:17 -04:00
const usedInvite = newInvites.find((inv:Discord.Invite)=>client.invites.get(inv.code)?.uses < inv.uses);
newInvites.forEach((inv:Discord.Invite)=>client.invites.set(inv.code,{uses: inv.uses, creator: inv.inviterId, channel: inv.channel.name}));
2023-03-05 05:04:10 -05:00
(client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [
new client.embed().setColor(client.config.embedColorGreen).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048})).setTitle(`${isBot} Joined: ${member.user.username}`).setDescription(`<@${member.user.id}>\n\`${member.user.id}\``).setFooter({text: `Total members: ${index}${suffix}`}).addFields(
2023-03-05 05:04:10 -05:00
{name: '🔹 Account Creation Date', value: `<t:${Math.round(member.user.createdTimestamp/1000)}>\n<t:${Math.round(member.user.createdTimestamp/1000)}:R>`},
{name: '🔹 Invite Data:', value: usedInvite ? `Invite: \`${usedInvite.code}\`\nCreated by: **${usedInvite.inviter?.username}**\nChannel: **#${usedInvite.channel.name}**` : 'No invite data could be fetched.'}
)]});
if (await client.punishments._content.findOne({'member': member.user.id, type: 'mute', expired: undefined})){
2023-08-29 20:21:53 -04:00
(client.channels.resolve(client.config.mainServer.channels.dcmod_chat) as Discord.TextChannel).send({embeds: [new client.embed().setColor(client.config.embedColorYellow).setTitle('Case evasion detected').setDescription(MessageTool.concatMessage(
`**${member.user.username}** (\`${member.user.id}\`) has been detected for case evasion.`,
'Timeout has been automatically added. (25 days)'
2023-08-29 20:21:53 -04:00
)).setTimestamp()]});
await client.punishments.addPunishment('mute', {time: '25d'}, client.user.id, '[AUTOMOD] Case evasion', member.user, member)
}
2023-03-05 05:04:10 -05:00
}
2022-11-25 04:46:51 -05:00
}