Add Anti-Spam Discord bot
Introduce a new Anti-Spam Discord bot project. Adds project metadata and scripts (package.json, .env.example, .gitignore, README, deploy-commands.js) and the full src implementation: command registration and handling, per-guild settings persistence, configuration parsing, spam detection logic (phishing URLs, suspicious TLDs, mass/role mentions, image+URL combos, new account heuristics), and the bot entrypoint (index.js) that enforces permissions, logs actions, and optionally bans offenders. README explains setup, required intents, and usage; per-server settings are stored under data/guild-settings.json. (package-lock.json added for dependency resolution.)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import "dotenv/config";
|
||||
import { REST, Routes } from "discord.js";
|
||||
import { antispamCommands } from "../src/commands.js";
|
||||
|
||||
const token = process.env.DISCORD_TOKEN;
|
||||
const appId = process.env.APPLICATION_ID?.trim();
|
||||
|
||||
if (!token) {
|
||||
console.error("Missing DISCORD_TOKEN in .env");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (!appId) {
|
||||
console.error("Missing APPLICATION_ID in .env");
|
||||
console.error("Find it in the Developer Portal → General Information → Application ID");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const guildId = process.env.DEPLOY_GUILD_ID?.trim();
|
||||
const rest = new REST().setToken(token);
|
||||
|
||||
try {
|
||||
if (guildId) {
|
||||
await rest.put(Routes.applicationGuildCommands(appId, guildId), {
|
||||
body: antispamCommands,
|
||||
});
|
||||
console.log(`Deployed ${antispamCommands.length} command(s) to guild ${guildId} (instant).`);
|
||||
} else {
|
||||
await rest.put(Routes.applicationCommands(appId), { body: antispamCommands });
|
||||
console.log(`Deployed ${antispamCommands.length} global command(s).`);
|
||||
console.log("Global commands can take up to an hour to appear in Discord.");
|
||||
console.log("For instant commands, set DEPLOY_GUILD_ID in .env and run again.");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Deploy failed:", error.rawBody ?? error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user