- About the Project
- Features
- Prerequisites
- Installation
- Configuration
- Running the Bot
- Discord Bot Setup
- Operational Notes
- Troubleshooting
- Contributing
- License
A Discord bot that provides a simple interface to enable or disable audit webhooks with a single click, helping avoid Discord rate limits during mass messaging events by toggling webhook configurations via a CRCON server API.
- Sends an embed with Enable and Disable buttons to a specified Discord channel.
- Displays the current webhook status ("Webhooks: Enabled" or "Webhooks: Disabled") or a warning if the configuration is unavailable.
- Fetches and stores the initial webhook configuration from the CRCON server.
- Enables/disables audit webhooks with one click to prevent rate limiting during mass messaging.
- Includes retry logic for Discord login and robust error handling for API requests.
- Clears the channel of previous messages before sending the control embed.
- Disables buttons when their action is not applicable (e.g., "Enable" disabled when webhooks are active).
- Node.js (v16 or higher) for local running, or Docker and Docker Compose for containerized deployment.
- A Discord bot token from the Discord Developer Portal.
- Access to a CRCON server with an API key.
- A Discord channel ID where the bot will operate.
- Clone or download this repository:
git clone https://github.com/hackletloose/hall-audit-webhook-toggle.git cd hall-audit-webhook-toggle
- For local running, install dependencies:
npm install
- For Docker, ensure Docker and Docker Compose are installed (no additional steps needed).
- Copy the example environment file:
cp .env.example .env
- Edit
.env
with your values:CRCON_SERVER=https://your-crcon-server.com CRCON_API_KEY=your_crcon_api_key DISCORD_TOKEN=your_discord_bot_token CHANNEL_ID=your_discord_channel_id
CRCON_SERVER
: URL of your CRCON server (e.g.,https://crcon.example.com
).CRCON_API_KEY
: API key for CRCON server authentication.DISCORD_TOKEN
: Discord bot token from the Developer Portal.CHANNEL_ID
: ID of the Discord channel for the bot’s embed.
- Ensure
.env
is configured. - Start the bot:
npm start
- The bot will log in, clear the channel, and send an embed with buttons.
- Ensure Docker and Docker Compose are installed.
- Configure
.env
as above. - Rename the docker compose example:
mv example.docker-compose.yml docker-compose.yml
- Build and run the container:
docker compose up -d
- View logs:
docker compose logs
- Stop the container:
docker compose down
- Rebuild after code changes:
docker compose up -d --build
- Go to the Discord Developer Portal and create a new application.
- Add a bot to the application and copy its token (set as
DISCORD_TOKEN
in.env
). - Enable the following intents under "Bot":
- Guilds
- Guild Messages
- Message Content
- Invite the bot to your server with the following permissions:
- View Channel
- Send Messages
- Manage Messages
- Embed Links
- Read Message History
- Copy the ID of the target channel and set it as
CHANNEL_ID
in.env
.
- On startup, the bot clears the specified channel and sends an embed with "Aktivieren" (Enable) and "Deaktivieren" (Disable) buttons.
- The embed shows:
- "Webhooks: Enabled" if webhooks are active.
- "Webhooks: Disabled" if webhooks are off (e.g., dummy URL or empty config).
- A warning if the CRCON config fetch fails, advising to restart or check the server.
- Buttons are disabled when their action is redundant (e.g., "Enable" disabled if webhooks are enabled).
- Use the "Disable" button before mass messaging to avoid Discord rate limits, then "Enable" to restore webhooks.
- Check logs (
docker compose logs
or console) for errors if the bot fails to start or respond. - If the warning appears, verify the CRCON server URL and API key, or restart the bot.
- Bot fails to log in: Verify
DISCORD_TOKEN
and ensure intents/permissions are enabled in the Developer Portal. - API errors: Check
CRCON_SERVER
andCRCON_API_KEY
. Ensure the CRCON server is reachable. - Channel not found: Confirm
CHANNEL_ID
is correct and the bot has channel access. - Buttons not working: Ensure the bot has "Manage Messages" and "Embed Links" permissions.
- Docker issues: Verify Docker is running,
.env
exists, and no port conflicts occur. - Warning in embed: If the webhook config fetch fails, check CRCON server connectivity or restart the container.
Submit issues or pull requests to improve the bot. Ensure changes are documented and tested.
This project is licensed under the MIT License.