depends on
About Discord Raid Alarm
DiscordRaidAlarm is a fully vanilla-friendly Rust plugin and Discord integration that alerts defenders when their base is under attack. It does not rely on Rust+ or any external “seismic sensors.” By detecting building damage in a standard Rust server (Oxide/uMod or Carbon), the system sends raid data to a PHP script with a MySQL database, and a Discord bot delivers real-time notifications to defenders via direct messages. You can either host your own single-tenant bot or register with our public multi-tenant bot (no hosting required). Once Steam-to-Discord mapping is in place, your players receive automated alerts about raids, even on completely vanilla Rust servers.If you need help configuring it, message me on Discord: CrypticRedhat.
1. Overview
DiscordRaidAlarm notifies Rust players on Discord if their base is under attack. Its core components:
- Rust Plugin: Captures damage events and posts them to a PHP script.
- PHP Script + MySQL: Stores raid data in a raid_events table.
- Discord Bot: Reads the table and DMs defenders.
You can either use:
- Our Public Multi-Tenant Bot (simplest; no hosting required), or
- A Self-Hosted Single-Tenant .exe (full control, optional).
This guide focuses first on the public multi-tenant bot approach—especially how to invite the bot and use
/registertenant.
2. Prerequisites
- Rust Server supporting Oxide/uMod or Carbon.
- A web host or cPanel environment for PHP + MySQL.
- A MySQL database (username, password, DB name, etc.).
- Token generated from it-tools.tech/token-generator (used across plugin & PHP script, and you’ll provide it to the multi-tenant bot).
- If you choose to self-host your own bot: A Windows machine and optionally a Discord Developer Portal application for a custom bot token.
3. Token Generation & Matching
- Go to it-tools.tech/token-generator → click generate.
- Use that random string for:
- Rust plugin config (API Auth Token),
- PHP script (API_TOKEN),
- And you’ll also provide it to the multi-tenant bot in /registertenant or your self-hosted bot config.
All must match exactly or you’ll see 401/403 errors.
4. Rust Plugin Setup (Oxide/uMod or Carbon)
- Obtain DiscordRaidAlarm.cs.
- Place in your Rust server’s plugin folder:
- Oxide: oxide/plugins/
- Carbon: Carbon/Plugins/
3. Load the plugin:
- Oxide: oxide.reload DiscordRaidAlarm or restart.
- Carbon: c.reload DiscordRaidAlarm.
4. Config:
- Check oxide/config/DiscordRaidAlarm.json or similar.
- Set "API URL" to your DiscordRaidAlarm.php location, e.g. https://yourdomain.com/DiscordRaidAlarm.php.
- Set "API Auth Token" to the same token from Step 3.
Verify no errors. Run oxide.plugins or carbon.plugins to confirm it’s loaded.
5. PHP API Setup
- Upload DiscordRaidAlarm.php to your web host.
- Edit lines like:
define('DB_HOST', 'localhost'); define('DB_NAME', 'my_database'); define('DB_USER', 'my_db_user'); define('DB_PASS', 'my_db_pass'); define('API_TOKEN', 'YOUR_RANDOM_TOKEN');
Make sure API_TOKEN matches your plugin.
Ensure you can reach DiscordRaidAlarm.php in a browser (it may show an error, that’s normal with no parameters).
6. Database Creation
- Create a MySQL DB or use an existing one.
- Import create_table.sql:
mysql -u my_db_user -p my_database < create_table.sql
3. Check for raid_events:
SHOW TABLES;
If it’s there, you’re set.
7. Using the Public Multi-Tenant Bot
If you don’t want to host a .exe, our public multi-tenant Discord bot can poll your raid_events for you. Below are the two main steps: inviting the bot, then registering your tenant via the /registertenant slash command.
7.1 Invite the Bot to Your Server
- Click this invite link:
It’s pre-configured with minimal but necessary permissions, including Send Messages (crucial for DM or channel posting) and other relevant scopes.
- Select your Discord server and authorize it.
- The bot will now appear in your server’s member list. If it can’t send messages or you want slash commands to work, ensure it has the right role/permission in the server. Typically “Send Messages,” “Embed Links,” “Read Messages History,” and “Use Application Commands” are enough.
7.2 Register Your Tenant with /registertenant
- Open a text channel (or any channel) in the same server where you invited the bot.
- Type /registertenant. You’ll see a form for:
api_url
(required) – The URL to your DiscordRaidAlarm.php.
api_token
(required) – The same token from your plugin + DiscordRaidAlarm.php.
steamlink_url
(required) – If you’re using a steam-to-discord link system.
steamlink_secret
(required) – Also for your steam link system.
bypass_token
(optional) – For some advanced steam link usage.
poll_interval
(optional) – How often the bot checks your raids, in seconds. Defaults to the global fallback if omitted.
Fill out each field carefully:
- api_url: e.g., https://yourdomain.com/DiscordRaidAlarm.php
- api_token: your random token.
- steamlink_url / steamlink_secret: If you do not have a steam linking system, just enter placeholders.
- (Optional) bypass_token or poll_interval if needed.
Press Enter. The bot will respond ephemerally with either “Tenant registered/updated successfully!” or an error message if something went wrong.
If successful, the bot automatically logs your server info (guild_id + config) in its multi-tenant DB.
From this point on, the bot polls your raid_events table.
Done! Whenever your plugin logs a raid, the bot sees it and DMs the defenders (assuming you have steam-to-discord mapping set up).
Important: You must run /registertenant from within the server that the bot is invited to. The bot automatically captures your guild_id from the slash command, linking that guild to the api_url + api_token you provided.
8. Self-Hosted Bot (Optional)
If you prefer hosting your own single-tenant .exe, skip Section 7 and do this:
- Create a Discord bot in the Developer Portal.
- Invite it with permissions like Send Messages, etc.
- Edit appsettings.json or .config:
-
{ "BotSettings": { "BotToken": "YOUR_BOT_TOKEN", "RaidApiUrl": "https://yourdomain.com/DiscordRaidAlarm.php", "RaidApiToken": "YOUR_RANDOM_TOKEN", "PollIntervalSeconds": "10" } }
- Run DiscordRaidAlarmBot.exe.
- It polls your raid_events table, DMs defenders.
9. Testing & Verification
- Trigger a test from your Rust server plugin if it supports a test command (like /raidalarm.test). Otherwise, damage a building block.
- Check your MySQL raid_events table:
-
SELECT * FROM raid_events;
- If a new row is added with processed=0, the bot should see it next poll cycle (every 10–30 seconds or your chosen interval).
- The bot (public multi-tenant or your own) sends direct messages to any defenders with known Discord IDs.
- If you see “Tenant registered/updated successfully!” from /registertenant but no raids are processed, check Troubleshooting.
10. Troubleshooting
-
No DMs:
- Possibly defenders’ privacy settings block DMs from that server’s members.
- The user might not be in the same Discord server.
- Steam ID → Discord ID mapping is missing if you rely on external link systems.
-
“Tenant registration failed” or 403/401 messages:
- Mismatched api_token between the Rust plugin, the DiscordRaidAlarm.php, or the data you entered in /registertenant.
- Typo in the api_url or server didn’t load the plugin.
-
Bot Not Sending:
- For the public multi-tenant bot, confirm you typed /registertenant in the correct server, and it responded with success.
- For your self-hosted bot, ensure the .exe is running, the token is valid, and it’s in your server with Send Messages permission.
-
Plugin Not Logging:
- Check the console logs for DiscordRaidAlarm.cs loading errors.
- Possibly it’s in the wrong folder for Oxide/Carbon, or you didn’t set “API Auth Token” in the plugin config.