mirror of
https://github.com/Sneed-Group/clanrocket-2
synced 2025-01-09 17:53:13 +00:00
Upload files to ''
This commit is contained in:
parent
fc977ac479
commit
dbc23b7cd4
3 changed files with 15 additions and 0 deletions
|
@ -1,2 +1,3 @@
|
||||||
DISCORD_BOT_TOKEN=YOUR_DISCORD_BOT_TOKEN_HERE
|
DISCORD_BOT_TOKEN=YOUR_DISCORD_BOT_TOKEN_HERE
|
||||||
DISCORD_APPLICATION_ID=your_application_id_here
|
DISCORD_APPLICATION_ID=your_application_id_here
|
||||||
|
PERSPECTIVE_API_KEY="Your_Perspective_Api_Key_Here"
|
13
index.js
13
index.js
|
@ -10,6 +10,7 @@ const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||||
const { REST } = require('@discordjs/rest');
|
const { REST } = require('@discordjs/rest');
|
||||||
const { Routes } = require('discord-api-types/v9');
|
const { Routes } = require('discord-api-types/v9');
|
||||||
const { QuickDB } = require("quick.db");
|
const { QuickDB } = require("quick.db");
|
||||||
|
const Perspective = require('perspective-api-client');
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
|
|
||||||
// Initialize Express.js app
|
// Initialize Express.js app
|
||||||
|
@ -26,6 +27,7 @@ if (!applicationId) {
|
||||||
console.error('Application ID not found in environment variables.');
|
console.error('Application ID not found in environment variables.');
|
||||||
process.exit(1); // Exit the process if application ID is missing
|
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
|
// Set up Discord slash commands
|
||||||
const commands = [
|
const commands = [
|
||||||
|
@ -70,10 +72,21 @@ 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;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
"discord.js": "^13.4.1",
|
"discord.js": "^13.4.1",
|
||||||
"dotenv": "^10.0.0",
|
"dotenv": "^10.0.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
|
"perspective-api-client": "^3.1.0",
|
||||||
"quick.db": "^9.1.7"
|
"quick.db": "^9.1.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue