-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Some bot's crushed app to avoid this, you can use
const { EmbedBuilder } = require('discord.js');
const fs = require('fs');
const path = require('path');
const BLOCKED_APPS_FILE = path.join(__dirname, 'blocked_apps.json');
const DEFAULT_BLOCKED_APPS = [
'Dank Memer',
'MEE6',
'Dyno',
'Carl-bot',
'Pokécord',
'Groovy',
'Hydra',
'Rythm',
'FredBoat',
'Tatsumaki',
'GAwesome Bot',
'UnbelievaBoat',
'Octave',
'Discord Music Bot',
'Airhorn Solutions'
];
class AppBlocker {
constructor() {
this.blockedApps = new Set(DEFAULT_BLOCKED_APPS);
this.loadBlockedApps();
}
loadBlockedApps() {
try {
if (fs.existsSync(BLOCKED_APPS_FILE)) {
const data = fs.readFileSync(BLOCKED_APPS_FILE, 'utf8');
const loaded = JSON.parse(data);
loaded.forEach(app => this.blockedApps.add(app));
}
} catch (error) {
this.saveBlockedApps();
}
}
saveBlockedApps() {
try {
fs.mkdirSync(path.dirname(BLOCKED_APPS_FILE), { recursive: true });
const data = JSON.stringify([...this.blockedApps], null, 2);
fs.writeFileSync(BLOCKED_APPS_FILE, data);
} catch (error) {}
}
shouldIgnoreMessage(message) {
if (message.author.bot && message.author.id !== message.client.user.id) {
const appName = message.author.username;
for (const blockedApp of this.blockedApps) {
if (appName.toLowerCase().includes(blockedApp.toLowerCase())) {
return true;
}
}
}
if (message.webhookId) {
return true;
}
if (message.system) {
return true;
}
return false;
}
addBlockedApp(appName) {
this.blockedApps.add(appName);
this.saveBlockedApps();
return `Приложение "${appName}" добавлено в черный список`;
}
removeBlockedApp(appName) {
let removed = false;
for (const blockedApp of this.blockedApps) {
if (blockedApp.toLowerCase().includes(appName.toLowerCase())) {
this.blockedApps.delete(blockedApp);
removed = true;
break;
}
}
if (removed) {
this.saveBlockedApps();
return `Приложение "${appName}" удалено из черного списка`;
}
return `Приложение "${appName}" не найдено в черном списке`;
}
getBlockedApps() {
return [...this.blockedApps].sort();
}
isBlocked(appName) {
for (const blockedApp of this.blockedApps) {
if (appName.toLowerCase().includes(blockedApp.toLowerCase())) {
return true;
}
}
return false;
}
}
module.exports = { AppBlocker };
if (require.main === module) {
const blocker = new AppBlocker();
console.log('Заблокированные приложения:', blocker.getBlockedApps());
const testMessages = [
{ author: { bot: true, username: 'Dank Memer' } },
{ author: { bot: false, username: 'Обычный пользователь' } },
{ author: { bot: true, username: 'MEE6' } },
{ author: { bot: true, username: 'Custom Bot' } }
];
testMessages.forEach((msg, i) => {
console.log(`Сообщение ${i + 1}:`, msg.author.username);
console.log('Игнорировать?', blocker.shouldIgnoreMessage(msg));
console.log('---');
});
}``
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels