♻️ fix code smells
This commit is contained in:
parent
a2e5f1545a
commit
acaf0b4dcb
7 changed files with 143 additions and 111 deletions
|
@ -20,24 +20,35 @@ export default {
|
||||||
|
|
||||||
if (channel === null) return;
|
if (channel === null) return;
|
||||||
|
|
||||||
(channel as TextChannel).send({
|
(channel as TextChannel)
|
||||||
embeds: [
|
.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(successColor)
|
new MessageEmbed()
|
||||||
.setAuthor({
|
.setColor(successColor)
|
||||||
name: "Member Joined",
|
.setAuthor({
|
||||||
iconURL: member.user.displayAvatarURL(),
|
name: "Member Joined",
|
||||||
})
|
iconURL: member.user.displayAvatarURL(),
|
||||||
.setDescription(`${member.user} ${member.user.tag}`)
|
})
|
||||||
.addFields([
|
.setDescription(`${member.user} ${member.user.tag}`)
|
||||||
{ name: "Account Age", value: `${member.user.createdAt}` },
|
.addFields([
|
||||||
])
|
{ name: "Account Age", value: `${member.user.createdAt}` },
|
||||||
.setTimestamp()
|
])
|
||||||
.setFooter({
|
.setTimestamp()
|
||||||
text: footerText,
|
.setFooter({
|
||||||
iconURL: footerIcon,
|
text: footerText,
|
||||||
}),
|
iconURL: footerIcon,
|
||||||
],
|
}),
|
||||||
});
|
],
|
||||||
|
})
|
||||||
|
.then(async () => {
|
||||||
|
logger.info(
|
||||||
|
`Audit log sent for event guildMemberAdd in guild ${member.guild.name} (${member.guild.id})`
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.catch(async () => {
|
||||||
|
logger.error(
|
||||||
|
`Audit log failed to send for event guildMemberAdd in guild ${member.guild.name} (${member.guild.id})`
|
||||||
|
);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,21 +20,32 @@ export default {
|
||||||
|
|
||||||
if (channel === null) return;
|
if (channel === null) return;
|
||||||
|
|
||||||
(channel as TextChannel).send({
|
(channel as TextChannel)
|
||||||
embeds: [
|
.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(errorColor)
|
new MessageEmbed()
|
||||||
.setAuthor({
|
.setColor(errorColor)
|
||||||
name: "Member Left",
|
.setAuthor({
|
||||||
iconURL: member.user.displayAvatarURL(),
|
name: "Member Left",
|
||||||
})
|
iconURL: member.user.displayAvatarURL(),
|
||||||
.setDescription(`${member.user} ${member.user.tag}`)
|
})
|
||||||
.setTimestamp()
|
.setDescription(`${member.user} ${member.user.tag}`)
|
||||||
.setFooter({
|
.setTimestamp()
|
||||||
text: footerText,
|
.setFooter({
|
||||||
iconURL: footerIcon,
|
text: footerText,
|
||||||
}),
|
iconURL: footerIcon,
|
||||||
],
|
}),
|
||||||
});
|
],
|
||||||
|
})
|
||||||
|
.then(async () => {
|
||||||
|
logger.info(
|
||||||
|
`Audit log sent for event guildMemberRemove in guild ${member.guild.name} (${member.guild.id})`
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.catch(async () => {
|
||||||
|
logger.error(
|
||||||
|
`Audit log failed to send for event guildMemberRemove in guild ${member.guild.name} (${member.guild.id})`
|
||||||
|
);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,23 +26,34 @@ export default {
|
||||||
|
|
||||||
if (channel === null) return;
|
if (channel === null) return;
|
||||||
|
|
||||||
(channel as TextChannel).send({
|
(channel as TextChannel)
|
||||||
embeds: [
|
.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(successColor)
|
new MessageEmbed()
|
||||||
.setDescription(
|
.setColor(successColor)
|
||||||
`
|
.setDescription(
|
||||||
|
`
|
||||||
**Interaction created by** ${interaction.user.username} **in** ${interaction.channel}
|
**Interaction created by** ${interaction.user.username} **in** ${interaction.channel}
|
||||||
`
|
`
|
||||||
)
|
)
|
||||||
.setThumbnail(interaction.user.displayAvatarURL())
|
.setThumbnail(interaction.user.displayAvatarURL())
|
||||||
.addFields([{ name: "Event", value: "interactionCreate" }])
|
.addFields([{ name: "Event", value: "interactionCreate" }])
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setFooter({
|
.setFooter({
|
||||||
text: footerText,
|
text: footerText,
|
||||||
iconURL: footerIcon,
|
iconURL: footerIcon,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
});
|
})
|
||||||
|
.then(async () => {
|
||||||
|
logger.info(
|
||||||
|
`Audit log sent for event interactionCreate in guild ${interaction?.guild?.name} (${interaction?.guild?.id})`
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.catch(async () => {
|
||||||
|
logger.error(
|
||||||
|
`Audit log failed to send for event interactionCreate in guild ${interaction?.guild?.name} (${interaction?.guild?.id})`
|
||||||
|
);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,26 +26,37 @@ export default {
|
||||||
|
|
||||||
if (channel === null) return;
|
if (channel === null) return;
|
||||||
|
|
||||||
(channel as TextChannel).send({
|
(channel as TextChannel)
|
||||||
embeds: [
|
.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(successColor)
|
new MessageEmbed()
|
||||||
.setAuthor({
|
.setColor(successColor)
|
||||||
name: message.author.username,
|
.setAuthor({
|
||||||
iconURL: message.author.displayAvatarURL(),
|
name: message.author.username,
|
||||||
})
|
iconURL: message.author.displayAvatarURL(),
|
||||||
.setDescription(
|
})
|
||||||
`
|
.setDescription(
|
||||||
|
`
|
||||||
**Message sent by** ${message.author} **deleted in** ${message.channel}
|
**Message sent by** ${message.author} **deleted in** ${message.channel}
|
||||||
${message.content}
|
${message.content}
|
||||||
`
|
`
|
||||||
)
|
)
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setFooter({
|
.setFooter({
|
||||||
text: footerText,
|
text: footerText,
|
||||||
iconURL: footerIcon,
|
iconURL: footerIcon,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
});
|
})
|
||||||
|
.then(async () => {
|
||||||
|
logger.info(
|
||||||
|
`Audit log sent for event messageDelete in guild ${message?.guild?.name} (${message?.guild?.id})`
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.catch(async () => {
|
||||||
|
logger.error(
|
||||||
|
`Audit log failed to send for event messageDelete in guild ${message?.guild?.name} (${message?.guild?.id})`
|
||||||
|
);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,25 +29,36 @@ export default {
|
||||||
|
|
||||||
if (channel === null) return;
|
if (channel === null) return;
|
||||||
|
|
||||||
(channel as TextChannel).send({
|
(channel as TextChannel)
|
||||||
embeds: [
|
.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(successColor)
|
new MessageEmbed()
|
||||||
.setAuthor({
|
.setColor(successColor)
|
||||||
name: newMessage.author.username,
|
.setAuthor({
|
||||||
iconURL: newMessage.author.displayAvatarURL(),
|
name: newMessage.author.username,
|
||||||
})
|
iconURL: newMessage.author.displayAvatarURL(),
|
||||||
.setDescription(
|
})
|
||||||
`
|
.setDescription(
|
||||||
|
`
|
||||||
**Message edited in** ${newMessage.channel} [jump to message](https://discord.com/channels/${newMessage.guild.id}/${newMessage.channel.id}/${newMessage.id})
|
**Message edited in** ${newMessage.channel} [jump to message](https://discord.com/channels/${newMessage.guild.id}/${newMessage.channel.id}/${newMessage.id})
|
||||||
`
|
`
|
||||||
)
|
)
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setFooter({
|
.setFooter({
|
||||||
text: footerText,
|
text: footerText,
|
||||||
iconURL: footerIcon,
|
iconURL: footerIcon,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
});
|
})
|
||||||
|
.then(async () => {
|
||||||
|
logger.info(
|
||||||
|
`Audit log sent for event messageUpdate in guild ${newMessage?.guild?.name} (${newMessage?.guild?.id})`
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.catch(async () => {
|
||||||
|
logger.error(
|
||||||
|
`Audit log failed to send for event messageUpdate in guild ${newMessage?.guild?.name} (${newMessage?.guild?.id})`
|
||||||
|
);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,7 +10,6 @@ import logger from "@logger";
|
||||||
// Models
|
// Models
|
||||||
import guildSchema from "@schemas/guild";
|
import guildSchema from "@schemas/guild";
|
||||||
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
import { ChannelType } from "discord-api-types/v10";
|
|
||||||
|
|
||||||
// Function
|
// Function
|
||||||
export default {
|
export default {
|
||||||
|
|
|
@ -55,29 +55,7 @@ export default async (client: Client) => {
|
||||||
|
|
||||||
const rRole = rMember.roles.cache.get(roleId);
|
const rRole = rMember.roles.cache.get(roleId);
|
||||||
|
|
||||||
if (!rRole) {
|
if (!rMember || !rRole) {
|
||||||
logger.error(`Role ${roleId} not found for shop role ${roleId}.`);
|
|
||||||
await shopRoleSchema
|
|
||||||
.deleteOne({
|
|
||||||
userId,
|
|
||||||
roleId,
|
|
||||||
guildId,
|
|
||||||
})
|
|
||||||
.then(async () => {
|
|
||||||
logger.verbose(
|
|
||||||
`Shop role document ${roleId} has been deleted from user ${userId}.`
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.catch(async (error) => {
|
|
||||||
logger.error(
|
|
||||||
`Error deleting shop role document ${roleId} from user ${userId}.`,
|
|
||||||
error
|
|
||||||
);
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!rMember) {
|
|
||||||
logger.error(`Member ${userId} not found for shop role ${roleId}.`);
|
logger.error(`Member ${userId} not found for shop role ${roleId}.`);
|
||||||
await shopRoleSchema
|
await shopRoleSchema
|
||||||
.deleteOne({
|
.deleteOne({
|
||||||
|
|
Loading…
Add table
Reference in a new issue