mirror of
https://github.com/Sneed-Group/clanrocket-2
synced 2024-12-23 11:42:48 -06:00
Upload files to ''
This commit is contained in:
parent
dbc23b7cd4
commit
a5fcc273ca
1 changed files with 29 additions and 11 deletions
40
index.js
40
index.js
|
@ -72,21 +72,10 @@ client.once('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
|
||||
client.on('messageCreate', async message => {
|
||||
if (message.author.bot) return;
|
||||
|
||||
analyzeMessage(message)
|
||||
|
||||
// Increment XP every 10 messages
|
||||
if (message.guild) {
|
||||
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
|
||||
client.on('interactionCreate', async interaction => {
|
||||
if (!interaction.isCommand()) return;
|
||||
|
|
Loading…
Reference in a new issue