Upload files to ''

This commit is contained in:
nodemixaholic 2024-03-25 18:59:00 +00:00
parent fc977ac479
commit dbc23b7cd4
3 changed files with 15 additions and 0 deletions

View file

@ -1,2 +1,3 @@
DISCORD_BOT_TOKEN=YOUR_DISCORD_BOT_TOKEN_HERE
DISCORD_APPLICATION_ID=your_application_id_here
PERSPECTIVE_API_KEY="Your_Perspective_Api_Key_Here"

View file

@ -10,6 +10,7 @@ const { SlashCommandBuilder } = require('@discordjs/builders');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { QuickDB } = require("quick.db");
const Perspective = require('perspective-api-client');
const express = require('express');
// Initialize Express.js app
@ -26,6 +27,7 @@ if (!applicationId) {
console.error('Application ID not found in environment variables.');
process.exit(1); // Exit the process if application ID is missing
}
const perspective = new Perspective({apiKey: process.env.PERSPECTIVE_API_KEY});
// Set up Discord slash commands
const commands = [
@ -70,10 +72,21 @@ 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;

View file

@ -14,6 +14,7 @@
"discord.js": "^13.4.1",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"perspective-api-client": "^3.1.0",
"quick.db": "^9.1.7"
}
}