Upload files to ''

This commit is contained in:
nodemixaholic 2024-03-25 19:23:26 +00:00
parent dbc23b7cd4
commit a5fcc273ca

View file

@ -72,21 +72,10 @@ client.once('ready', () => {
console.log('Bot is ready!'); console.log('Bot is ready!');
}); });
async function analyzeMessage(message) {
const result = await perspective.analyze(message.content);
if (result.toxicity > 0.93) {
// Take moderation action
message.delete();
message.channel.send(`${message.author}, your message has been removed for toxicity.`);
}
}
// Discord.js event listener for when a message is received // Discord.js event listener for when a message is received
client.on('messageCreate', async message => { client.on('messageCreate', async message => {
if (message.author.bot) return; if (message.author.bot) return;
analyzeMessage(message)
// Increment XP every 10 messages // Increment XP every 10 messages
if (message.guild) { if (message.guild) {
const guildId = message.guild.id; const guildId = message.guild.id;
@ -102,6 +91,35 @@ client.on('messageCreate', async message => {
} }
}); });
client.on('messageCreate', async message => {
if (message.author.bot) { return; }
try {
const result = await perspective.analyze(message.content);
console.log(`TOXICITY [0-1]: ${result.attributeScores.TOXICITY.summaryScore.value}`)
if (message.member.permissions.has("ADMINISTRATOR")) { return; }
if (result.attributeScores.TOXICITY.summaryScore.value > 0.93) {
// Take moderation action
message.delete();
message.channel.send(`${message.author}, your message has been removed for toxicity.`);
}
} catch {}
})
client.on('messageUpdate', async (oldMessage, newMessage) => {
if (newMessage.author.bot) { return; }
console.log(`${oldMessage} ==> ${newMessage}`)
try {
const result = await perspective.analyze(newMessage.content);
console.log(`UPDATED TOXICITY [0-1]: ${result.attributeScores.TOXICITY.summaryScore.value}`)
if (newMessage.member.permissions.has("ADMINISTRATOR")) { return; }
if (result.attributeScores.TOXICITY.summaryScore.value > 0.93) {
// Take moderation action
newMessage.delete();
newMessage.channel.send(`${newMessage.author}, your message has been removed for toxicity.`);
}
} catch {}
});
// Discord.js event listener for when a slash command is used // Discord.js event listener for when a slash command is used
client.on('interactionCreate', async interaction => { client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return; if (!interaction.isCommand()) return;