Documentation
Complete reference for BetterGhast v3.0. Everything you need to set up, configure, and use the bot on your Discord server.
About BetterGhast
BetterGhast is an all-in-one Discord server management bot. It started as a tag management tool and has grown into a full-featured bot covering moderation, community engagement, and automation.
Core areas:
- Tag System — Reusable message snippets with templates, permissions, and analytics
- Moderation — Warning system with auto-escalation, auto-response triggers, anti-spam protection
- Community — Welcome messages, reaction roles, ticket system, leveling with XP, polls
BetterGhast is built with Kotlin, JDA 6, and MariaDB. It runs as a Docker container on any Linux server.
Setup & Installation
Quick Deploy (Docker)
git clone https://github.com/Krogie/BetterGhast.git
cd BetterGhast
bash deploy.sh
The deploy script handles everything: Docker installation, database setup, and bot configuration. It will ask you for your Discord bot token.
Discord Developer Portal
- Go to discord.com/developers/applications
- Create an application or select your existing one
- Under Bot, enable Message Content Intent and Server Members Intent
- Under OAuth2 > URL Generator, select scopes
bot+applications.commands - Select the required permissions (see below) and invite the bot
Required Permissions
| Permission | Used For |
|---|---|
| Send Messages | All features (tags, responses, notifications) |
| Manage Messages | Deleting !t prefix commands, anti-spam message deletion |
| Manage Channels | Ticket system (creating/deleting ticket channels) |
| Manage Roles | Reaction roles, leveling roles, auto-role on join |
| Moderate Members | Warning escalation (muting users via timeout) |
| Kick Members | Warning escalation (kicking at threshold) |
| Ban Members | Warning escalation (banning at threshold) |
| Embed Links | Rich tag content display |
| Attach Files | Tag export, ticket transcripts |
| Read Message History | Ticket transcripts, anti-spam |
Tags — Overview
Tags are reusable message snippets that can be triggered by anyone in your server. They support full Discord markdown, media URLs, templates with placeholders, and role-based access control.
!t keyword in chat. The bot deletes the trigger message and posts the tag content. Slash commands require the Manage Messages permission.Tag Styles
- Accent Embed — Wrapped in a container with your custom accent color. Supports headers (lines starting with
###) and media galleries. - No Accent — Same container formatting but without the colored accent bar.
- Raw Message — Sent as a plain text message with no embed. Useful for simple text responses.
Create & Edit Tags
| Command | Description |
|---|---|
/tags manage name:<keyword> | Opens a modal to create a new tag or edit an existing one |
/tags manage name:<keyword> remove:true | Deletes a tag (with confirmation prompt) |
The modal lets you set:
- Keywords — Comma-separated list of trigger words. The first one is the primary keyword. Example:
nolfg, m, lfg - Content — The tag message. Supports full Discord markdown, headers (
###), and trailing media URLs. - Style — Choose Accent, No Accent, or Raw.
Media URLs
If your tag content ends with a URL separated by a blank line, it will be displayed as an embedded media gallery (images, GIFs, videos).
### Welcome to our server!
Please read the rules in #rules before chatting.
https://example.com/welcome-banner.png
Templates & Placeholders
Tags support dynamic placeholders that are replaced when the tag is triggered:
| Placeholder | Replaced With |
|---|---|
{user} | Display name of the user who triggered the tag |
{user.tag} | Username (e.g. john_doe) |
{user.mention} | User mention (clickable @mention) |
{user.id} | User's Discord ID |
{channel} | Name of the channel where the tag was triggered |
{channel.mention} | Channel mention (clickable #link) |
{server} | Server name |
{server.members} | Total member count of the server |
{date} | Current date and time (dd.MM.yyyy HH:mm) |
{mention} | Mention of a user referenced in the trigger |
Hey {user.mention}, welcome to {server}! will output Hey @John, welcome to My Server! when triggered.Role Permissions
| Command | Description |
|---|---|
/tags permissions name:<keyword> | View the current role restriction for a tag |
/tags permissions name:<keyword> role:@Role | Restrict the tag to members with this role |
When a tag has a role restriction, only members with that role can trigger it via !t. Members without the role will get no response (silent fail). To remove a restriction, set the role to @everyone.
Tag Analytics
| Command | Description |
|---|---|
/tags analytics | View usage analytics for all tags |
Shows:
- Top Users — Who uses tags the most (top 10)
- Usage Trends — Daily usage for the last 7 days
- Unused Tags — Tags that have never been triggered (cleanup suggestions)
Search, Stats & Export
| Command | Description |
|---|---|
/tags show | List all tags with pagination (15 per page) |
/tags search query:<term> | Search tags by keyword or content |
/tags stats | Usage statistics with visual bar chart (top 10 tags) |
/tags info name:<keyword> | Detailed info: keywords, style, usages, creator, required role |
/tags export | Export all server tags as a JSON file |
/tags help | Quick reference of all commands |
Warning System Moderator
A full warning system with automatic escalation. Moderators can warn users, and the bot automatically takes action when thresholds are reached.
| Command | Description |
|---|---|
/warn @user reason:<text> | Issue a warning. Shows current count and any escalation taken. |
/warnings @user | View all warnings for a user (active and expired) |
/clearwarning id:<number> | Remove a specific warning by its ID |
Escalation Thresholds
Default thresholds (configurable via WARN_THRESHOLDS in .env):
| Warnings | Action |
|---|---|
| 3 | Mute (1 hour timeout) |
| 5 | Kick from server |
| 7 | Ban from server |
Warning Decay
Warnings automatically expire after a configurable number of days (default: 30). Expired warnings are marked as inactive and no longer count toward escalation thresholds. A background job checks for expired warnings daily.
Auto-Responses Admin
Automatically reply with a tag when a message matches a keyword or regex pattern. Useful for FAQ automation.
| Command | Description |
|---|---|
/autoresponse add pattern:<text> tag:<keyword> | Add a trigger. Optionally set regex:true and channel:#channel |
/autoresponse remove id:<number> | Remove a trigger by ID |
/autoresponse list | List all triggers with their IDs, patterns, and status |
/autoresponse toggle id:<number> | Enable or disable a trigger without deleting it |
/autoresponse add pattern:how do i join tag:join-instructions — Whenever someone says "how do i join", the bot sends the join-instructions tag.Regex Mode
Set regex:true when adding a trigger to use regular expressions. Example: pattern:(?i)how\s+(do|can)\s+i\s+join matches "How do I join", "how can i join", etc.
Per-Trigger Cooldown
Each trigger has a 30-second cooldown by default to prevent spam. The cooldown is per-guild per-trigger.
Anti-Spam Admin
Protects your server from spam, duplicate messages, suspicious links, and Discord invite links.
| Command | Description |
|---|---|
/antispam toggle | Enable or disable anti-spam for the server |
/antispam ratelimit messages:<n> window:<ms> | Set rate limit (default: 5 messages per 5000ms) |
/antispam linkfilter enabled:<bool> | Toggle link filtering (blocks unknown URLs) |
/antispam invitefilter enabled:<bool> | Toggle invite filtering (blocks Discord invites) |
/antispam whitelist action:add domain:<url> | Whitelist a domain from link filtering |
/antispam whitelist action:remove domain:<url> | Remove a domain from the whitelist |
/antispam status | Show current anti-spam configuration |
What Gets Detected
- Rate Limiting — Too many messages in a short time window. Configurable threshold and window.
- Duplicate Detection — Repeated identical messages (based on content hash).
- Link Filter — Messages containing URLs not on the whitelist.
- Invite Filter — Messages containing Discord server invite links.
Spam messages are automatically deleted. Optionally, the user receives an automatic warning via the warning system.
Users with the "Manage Messages" permission are exempt from anti-spam checks.
Welcome Messages Admin
Greet new members and say goodbye to leaving ones. Supports placeholders, auto-role, and optional DMs.
| Command | Description |
|---|---|
/welcome channel #channel | Set which channel receives welcome/leave messages |
/welcome message text:<text> | Set the join message. Supports placeholders. |
/welcome leave text:<text> | Set the leave message. Supports placeholders. |
/welcome autorole role:@Role | Automatically assign a role to new members |
/welcome dm enabled:true text:<text> | Send a DM to new members on join |
/welcome test | Preview the welcome message using yourself as the "new member" |
/welcome status | Show current welcome configuration |
Welcome to {server}, {user.mention}! You are member #{server.members}.All placeholders from the Tags Templates section work in welcome messages too.
Reaction Roles Admin
Let members assign themselves roles by clicking buttons or selecting from dropdowns.
| Command | Description |
|---|---|
/rolepanel create title:<text> style:buttons | Create a new role panel (buttons or dropdown) |
/rolepanel addrole panel:<id> role:@Role label:<text> | Add a role to the panel. Optional: emoji: |
/rolepanel send panel:<id> | Post the panel in the current channel |
/rolepanel delete panel:<id> | Delete a panel |
/rolepanel list | Show all panels for this server |
Button vs Dropdown
- Buttons (default) — Each role gets its own button. Click to toggle. Supports up to 25 roles (5 rows of 5).
- Dropdown — All roles in a single select menu. Members can select multiple roles at once.
How It Works
When a member clicks a button or selects a role from the dropdown, the bot toggles the role: adds it if the member doesn't have it, removes it if they do. No additional permissions needed from the member.
Ticket System Public
A support ticket system where members can create private channels for help requests.
| Command | Description |
|---|---|
/ticket setup supportrole:@Role | Set up the ticket system. Posts a panel with a "Create Ticket" button. Optional: categories:support,bug,feedback |
/ticket create | Create a new ticket. Optional: category:bug |
/ticket claim | Claim a ticket (mark yourself as the handler) |
/ticket close | Close the current ticket (with confirmation) |
/ticket transcript | Generate a markdown transcript of the ticket |
How Tickets Work
- An admin runs
/ticket setupto configure the support role and post a ticket panel. - Members click "Create Ticket" or use
/ticket createto open a ticket. - A private channel is created visible only to the member and the support team.
- Support staff can
/ticket claimthe ticket to indicate they are handling it. - When resolved, anyone can
/ticket close. A transcript can be generated before closing.
Leveling & XP Public
Members earn XP by chatting. As they level up, they can unlock special roles.
User Commands
| Command | Description |
|---|---|
/rank | View your level, XP, and progress to next level |
/rank @user | View someone else's rank |
/top | Server leaderboard (top 10) |
/top page:2 | View other pages of the leaderboard |
Admin Commands Admin
| Command | Description |
|---|---|
/xp toggle | Enable or disable the leveling system |
/xp addrole level:5 role:@Active | Assign a role when a member reaches level 5 |
/xp removerole level:5 | Remove a level role reward |
/xp multiplier channel:#chat multiplier:1.5 | Set 1.5x XP in a specific channel |
/xp status | Show leveling configuration |
How XP Works
- Members earn 15-25 XP per message (randomized)
- XP cooldown: 60 seconds between gains (prevents spam grinding)
- Level formula:
level = floor(0.1 * sqrt(xp)) - Level roles are automatically assigned when a member levels up
- Channel multipliers let you boost or reduce XP in specific channels
Polls Public
Create polls with buttons for voting. Supports time limits, anonymous voting, and multi-choice.
| Command | Description |
|---|---|
/poll question:<text> options:<opt1,opt2,opt3> | Create a basic poll |
/poll ... duration:1h | Auto-close after 1 hour. Supports: 30m, 1h, 1d, etc. |
/poll ... anonymous:true | Hide voter names in results |
/poll ... multichoice:true | Allow members to vote for multiple options |
How Polls Work
- Each option gets a vote button. Members click to vote (click again to unvote).
- Vote counts are updated live on the message.
- Polls can be closed manually by the creator or any admin, or automatically after the duration expires.
- Final results are posted when the poll closes.
Configuration
All configuration is done via the .env file. Here is a complete reference:
| Variable | Description | Default |
|---|---|---|
DISCORD_TOKEN | Your Discord bot token | required |
DB_HOST | MariaDB host | required |
DB_PORT | MariaDB port | 3306 |
DB_NAME | Database name | required |
DB_USER | Database user | required |
DB_PASSWORD | Database password | required |
ALLOWED_GUILDS | Comma-separated guild IDs (empty = all) | empty |
TAG_COOLDOWN_MS | Per-channel tag cooldown in ms | 2500 |
ACCENT_COLOR | Embed accent color (hex without #) | B5C8B4 |
WARN_DECAY_DAYS | Days until warnings auto-expire | 30 |
WARN_THRESHOLDS | Escalation rules (count:action pairs) | 3:mute,5:kick,7:ban |
ANTISPAM_RATE_LIMIT | Max messages in rate window | 5 |
ANTISPAM_RATE_WINDOW | Rate limit window in ms | 5000 |
LEVELING_XP_MIN | Minimum XP per message | 15 |
LEVELING_XP_MAX | Maximum XP per message | 25 |
LEVELING_COOLDOWN | XP gain cooldown in ms | 60000 |
All Commands
Tags
| Command | Permission | Description |
|---|---|---|
!t keyword | Public | Trigger a tag |
/tags manage | Mod | Create/edit/delete tags |
/tags show | Mod | List all tags |
/tags search | Mod | Search tags |
/tags stats | Mod | Usage statistics |
/tags info | Mod | Tag details |
/tags export | Mod | Export as JSON |
/tags analytics | Mod | Usage analytics |
/tags permissions | Mod | Role restrictions |
/tags help | Mod | Command reference |
Moderation
| Command | Permission | Description |
|---|---|---|
/warn | Mod | Issue a warning |
/warnings | Mod | View warnings |
/clearwarning | Mod | Remove warning |
/autoresponse | Admin | Auto-response triggers |
/antispam | Admin | Anti-spam config |
Community
| Command | Permission | Description |
|---|---|---|
/welcome | Admin | Welcome system config |
/rolepanel | Admin | Reaction role panels |
/ticket setup | Admin | Ticket system setup |
/ticket create | Public | Open a ticket |
/ticket close/claim/transcript | Public | Ticket actions |
/rank | Public | View level & XP |
/top | Public | Leaderboard |
/xp | Admin | Leveling config |
/poll | Public | Create polls |
/ask | Public | Ask KrogieBot (AI) |
/help | Public | Command overview |