Skip to content

Commit

Permalink
Few fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaUrsa committed Feb 20, 2024
1 parent 2518776 commit d29f201
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/discord/utils/trust.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,20 @@ export async function addedVerified(
return;
}

if (roleId === env.ROLE_VERIFIED && !memberData.trusted) {
if (roleId === env.ROLE_VERIFIED) {
if (memberData.trusted) {
if (guildData.channel_trust) {
const auditLog = await discordClient.channels.fetch(guildData.channel_trust) as TextChannel;
await auditLog.send(stripIndents`${newMember.displayName} had the verified role applied, \
but they were already marked at trusted in the database, so no message was sent`);

// /events/guildMemberUpdate will recognize that the verified rol has been added
// and will then activate addedVerified() above
}
return;
}
if (newMember.joinedAt
&& newMember.joinedAt < new Date(Date.now() - 1000 * 60 * 60 * 24)) {
&& newMember.joinedAt > new Date(Date.now() - 1000 * 60 * 60 * 24)) {
// log.debug(F, `${newMember.displayName} verified!`);
// let colorValue = 1;

Expand Down Expand Up @@ -198,8 +209,8 @@ export async function addedVerified(

if (guildData.channel_trust) {
const auditLog = await discordClient.channels.fetch(guildData.channel_trust) as TextChannel;
await auditLog.send(stripIndents`. **${newMember.displayName} had the verified role applied, but they joined\
over a week ago, so no welcome message was sent.*`);
await auditLog.send(stripIndents`${newMember.displayName} had the verified role applied, but they joined\
over a week ago, so no welcome message was sent.`);

// /events/guildMemberUpdate will recognize that the verified rol has been added
// and will then activate addedVerified() above
Expand Down Expand Up @@ -312,8 +323,8 @@ export default async function trust(

if (guildData.channel_trust) {
const auditLog = await discordClient.channels.fetch(guildData.channel_trust) as TextChannel;
await auditLog.send(stripIndents`. **${member.displayName} is above the set trust score of \
${guildData.trust_score_limit}, I removed the Unverified role and added Verified*`);
await auditLog.send(stripIndents`. ${member.displayName} is above the set trust score of \
${guildData.trust_score_limit}, I removed the Unverified role and added Verified*`);

// /events/guildMemberUpdate will recognize that the verified rol has been added
// and will then activate addedVerified() above
Expand All @@ -322,7 +333,7 @@ export default async function trust(

if (bannedGuilds.length > 0) {
modThreadMessage = stripIndents`**${member.displayName} has joined the guild, \
they are banned on ${bannedGuilds.length} other guilds!** <@&${guildData.role_moderator}>`;
they are banned on ${bannedGuilds.length} other guilds!** <@&${guildData.role_moderator}>`;
emoji = '👀';
}

Expand Down Expand Up @@ -390,8 +401,8 @@ export default async function trust(
const trustAverage = guildData.trust_score_total / guildData.trust_score_count;
let trustMessage = `Trust Score Average = ${trustAverage}`;
if (trustScoreData.trustScore < trustAverage) {
trustMessage += stripIndents`. **User is below the set trust score of ${guildData.trust_score_limit}, \
I did not remove the <@&${env.ROLE_UNVERIFIED}> role**`;
trustMessage += stripIndents`. User is below the set trust score of ${guildData.trust_score_limit}, \
I did not remove the <@&${env.ROLE_UNVERIFIED}> role`;
}

await auditLog.send(trustMessage);
Expand Down

0 comments on commit d29f201

Please sign in to comment.