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

Compare commits

..

3 Commits

Author SHA1 Message Date
toast-ts
3828a0e35c Hacky workaround for timestamp thing when member is banned 2024-01-31 23:57:56 +11:00
toast-ts
3150379c79 Fix up embed formatting 2024-01-31 23:57:40 +11:00
toast-ts
9396e97ae5 Attempt to fix regex when updating case 2024-01-31 23:35:18 +11:00
3 changed files with 12 additions and 5 deletions

View File

@ -10,7 +10,7 @@ export default class Case {
if (channel && channel.type === Discord.ChannelType.GuildText) { if (channel && channel.type === Discord.ChannelType.GuildText) {
const messages = await channel.messages.fetch({limit: 3}); const messages = await channel.messages.fetch({limit: 3});
messages.forEach(async message=>{ messages.forEach(async message=>{
if (message?.embeds[0]?.title.match(new RegExp(`Case #${caseId}`))) { if (message?.embeds[0]?.title && message?.embeds[0]?.title.match(new RegExp(`Case #${caseId}`))) {
const findIndex = message?.embeds[0].fields.findIndex(x=>x.name === 'Reason'); const findIndex = message?.embeds[0].fields.findIndex(x=>x.name === 'Reason');
await message.edit({embeds: [new client.embed(message.embeds[0]).spliceFields(findIndex, 1, {name: 'Reason', value: `\`${reason}\``})]}); await message.edit({embeds: [new client.embed(message.embeds[0]).spliceFields(findIndex, 1, {name: 'Reason', value: `\`${reason}\``})]});
} }

View File

@ -7,9 +7,11 @@ export default class GuildBanAdd {
if (!banLog) return console.log(`Member was banned from ${member.guild.name} but no audit log for this member.`) if (!banLog) return console.log(`Member was banned from ${member.guild.name} but no audit log for this member.`)
const {executor, target, reason } = banLog; const {executor, target, reason } = banLog;
if (target.id === member.user.id) { if (target.id === member.user.id) {
const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048})).setTitle(`Member Banned: ${target.username}`).setDescription(`🔹 **User**\n<@${target.id}>\n\`${target.id}\``).addFields( const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048}))
.setTitle(`Member Banned: ${target.username}`).addFields(
{name: '🔹 User', value: `<@${target.id}>\n\`${target.id}\``},
{name: '🔹 Moderator', value: `<@${executor.id}>\n\`${executor.id}\``}, {name: '🔹 Moderator', value: `<@${executor.id}>\n\`${executor.id}\``},
{name: '🔹 Reason', value: `${reason === null ? 'Reason unspecified': reason}`} {name: '🔹 Reason', value: reason === null ? 'Reason unspecified': reason}
); );
if (!await client.userLevels.fetchUser(member.user.id)) embed.setFooter({text: 'Rank data has been wiped.'}); if (!await client.userLevels.fetchUser(member.user.id)) embed.setFooter({text: 'Rank data has been wiped.'});
(client.channels.resolve(client.config.dcServer.channels.logs) as Discord.TextChannel).send({embeds: [embed]}) (client.channels.resolve(client.config.dcServer.channels.logs) as Discord.TextChannel).send({embeds: [embed]})

View File

@ -4,11 +4,16 @@ export default class GuildMemberRemove {
static async run(client:TClient, member:Discord.GuildMember){ static async run(client:TClient, member:Discord.GuildMember){
if (!client.config.botSwitches.logs) return; if (!client.config.botSwitches.logs) return;
if (!member.joinedTimestamp || member.guild?.id != client.config.dcServer.id) return; if (!member.joinedTimestamp || member.guild?.id != client.config.dcServer.id) return;
if (client.guilds.cache.get(client.config.dcServer.id).bans.cache.has(member.id)) return await client.userLevels.deleteUser(member.id); if (client.guilds.cache.get(client.config.dcServer.id).bans.cache.has(member.id)) {
(client.channels.resolve(client.config.dcServer.channels.logs) as Discord.TextChannel).send(`**${member.user.username}**'s join date is <t:${Math.round(member.joinedTimestamp/1000)}>`)
return await client.userLevels.deleteUser(member.id);
};
let isBot = 'Bot'; let isBot = 'Bot';
if (!member.user.bot) isBot = 'Member'; if (!member.user.bot) isBot = 'Member';
const levelData = await client.userLevels.fetchUser(member.id); const levelData = await client.userLevels.fetchUser(member.id);
const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048}) as string).setTitle(`${isBot} Left: ${member.user.username}`).setDescription(`<@${member.user.id}>\n\`${member.user.id}\``).addFields( const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048}) as string)
.setTitle(`${isBot} Left: ${member.user.username}`).addFields(
{name: '🔹 User', value: `<@${member.user.id}>\n\`${member.user.id}\``},
{name: '🔹 Account Creation Date', value: `<t:${Math.round(member.user.createdTimestamp/1000)}>\n<t:${Math.round(member.user.createdTimestamp/1000)}:R>`}, {name: '🔹 Account Creation Date', value: `<t:${Math.round(member.user.createdTimestamp/1000)}>\n<t:${Math.round(member.user.createdTimestamp/1000)}:R>`},
{name: '🔹 Server Join Date', value: `<t:${Math.round(member.joinedTimestamp/1000)}>\n<t:${Math.round(member.joinedTimestamp/1000)}:R>`}, {name: '🔹 Server Join Date', value: `<t:${Math.round(member.joinedTimestamp/1000)}>\n<t:${Math.round(member.joinedTimestamp/1000)}:R>`},
{name: `🔹 Roles: ${member.roles.cache.size - 1}`, value: `${member.roles.cache.size > 1 ? member.roles.cache.filter((x)=>x.id !== member.guild.roles.everyone.id).sort((a,b)=>b.position - a.position).map(x=>x).join(member.roles.cache.size > 4 ? ' ' : '\n').slice(0,1024) : 'No roles'}`, inline: true} {name: `🔹 Roles: ${member.roles.cache.size - 1}`, value: `${member.roles.cache.size > 1 ? member.roles.cache.filter((x)=>x.id !== member.guild.roles.everyone.id).sort((a,b)=>b.position - a.position).map(x=>x).join(member.roles.cache.size > 4 ? ' ' : '\n').slice(0,1024) : 'No roles'}`, inline: true}