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

  1. Go to discord.com/developers/applications
  2. Create an application or select your existing one
  3. Under Bot, enable Message Content Intent and Server Members Intent
  4. Under OAuth2 > URL Generator, select scopes bot + applications.commands
  5. Select the required permissions (see below) and invite the bot

Required Permissions

PermissionUsed For
Send MessagesAll features (tags, responses, notifications)
Manage MessagesDeleting !t prefix commands, anti-spam message deletion
Manage ChannelsTicket system (creating/deleting ticket channels)
Manage RolesReaction roles, leveling roles, auto-role on join
Moderate MembersWarning escalation (muting users via timeout)
Kick MembersWarning escalation (kicking at threshold)
Ban MembersWarning escalation (banning at threshold)
Embed LinksRich tag content display
Attach FilesTag export, ticket transcripts
Read Message HistoryTicket 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.

Tip: Anyone can trigger tags with !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

CommandDescription
/tags manage name:<keyword>Opens a modal to create a new tag or edit an existing one
/tags manage name:<keyword> remove:trueDeletes 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:

PlaceholderReplaced 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
Example: A tag with content Hey {user.mention}, welcome to {server}! will output Hey @John, welcome to My Server! when triggered.

Role Permissions

CommandDescription
/tags permissions name:<keyword>View the current role restriction for a tag
/tags permissions name:<keyword> role:@RoleRestrict 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

CommandDescription
/tags analyticsView 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

CommandDescription
/tags showList all tags with pagination (15 per page)
/tags search query:<term>Search tags by keyword or content
/tags statsUsage statistics with visual bar chart (top 10 tags)
/tags info name:<keyword>Detailed info: keywords, style, usages, creator, required role
/tags exportExport all server tags as a JSON file
/tags helpQuick 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.

CommandDescription
/warn @user reason:<text>Issue a warning. Shows current count and any escalation taken.
/warnings @userView 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):

WarningsAction
3Mute (1 hour timeout)
5Kick from server
7Ban 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.

CommandDescription
/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 listList all triggers with their IDs, patterns, and status
/autoresponse toggle id:<number>Enable or disable a trigger without deleting it
Example: /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.

CommandDescription
/antispam toggleEnable 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 statusShow 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.

CommandDescription
/welcome channel #channelSet 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:@RoleAutomatically assign a role to new members
/welcome dm enabled:true text:<text>Send a DM to new members on join
/welcome testPreview the welcome message using yourself as the "new member"
/welcome statusShow current welcome configuration
Example message: 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.

CommandDescription
/rolepanel create title:<text> style:buttonsCreate 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 listShow 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.

CommandDescription
/ticket setup supportrole:@RoleSet up the ticket system. Posts a panel with a "Create Ticket" button. Optional: categories:support,bug,feedback
/ticket createCreate a new ticket. Optional: category:bug
/ticket claimClaim a ticket (mark yourself as the handler)
/ticket closeClose the current ticket (with confirmation)
/ticket transcriptGenerate a markdown transcript of the ticket

How Tickets Work

  1. An admin runs /ticket setup to configure the support role and post a ticket panel.
  2. Members click "Create Ticket" or use /ticket create to open a ticket.
  3. A private channel is created visible only to the member and the support team.
  4. Support staff can /ticket claim the ticket to indicate they are handling it.
  5. When resolved, anyone can /ticket close. A transcript can be generated before closing.
Limits: Maximum 50 open tickets per server to prevent channel spam.

Leveling & XP Public

Members earn XP by chatting. As they level up, they can unlock special roles.

User Commands

CommandDescription
/rankView your level, XP, and progress to next level
/rank @userView someone else's rank
/topServer leaderboard (top 10)
/top page:2View other pages of the leaderboard

Admin Commands Admin

CommandDescription
/xp toggleEnable or disable the leveling system
/xp addrole level:5 role:@ActiveAssign a role when a member reaches level 5
/xp removerole level:5Remove a level role reward
/xp multiplier channel:#chat multiplier:1.5Set 1.5x XP in a specific channel
/xp statusShow 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.

CommandDescription
/poll question:<text> options:<opt1,opt2,opt3>Create a basic poll
/poll ... duration:1hAuto-close after 1 hour. Supports: 30m, 1h, 1d, etc.
/poll ... anonymous:trueHide voter names in results
/poll ... multichoice:trueAllow 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:

VariableDescriptionDefault
DISCORD_TOKENYour Discord bot tokenrequired
DB_HOSTMariaDB hostrequired
DB_PORTMariaDB port3306
DB_NAMEDatabase namerequired
DB_USERDatabase userrequired
DB_PASSWORDDatabase passwordrequired
ALLOWED_GUILDSComma-separated guild IDs (empty = all)empty
TAG_COOLDOWN_MSPer-channel tag cooldown in ms2500
ACCENT_COLOREmbed accent color (hex without #)B5C8B4
WARN_DECAY_DAYSDays until warnings auto-expire30
WARN_THRESHOLDSEscalation rules (count:action pairs)3:mute,5:kick,7:ban
ANTISPAM_RATE_LIMITMax messages in rate window5
ANTISPAM_RATE_WINDOWRate limit window in ms5000
LEVELING_XP_MINMinimum XP per message15
LEVELING_XP_MAXMaximum XP per message25
LEVELING_COOLDOWNXP gain cooldown in ms60000

All Commands

Tags

CommandPermissionDescription
!t keywordPublicTrigger a tag
/tags manageModCreate/edit/delete tags
/tags showModList all tags
/tags searchModSearch tags
/tags statsModUsage statistics
/tags infoModTag details
/tags exportModExport as JSON
/tags analyticsModUsage analytics
/tags permissionsModRole restrictions
/tags helpModCommand reference

Moderation

CommandPermissionDescription
/warnModIssue a warning
/warningsModView warnings
/clearwarningModRemove warning
/autoresponseAdminAuto-response triggers
/antispamAdminAnti-spam config

Community

CommandPermissionDescription
/welcomeAdminWelcome system config
/rolepanelAdminReaction role panels
/ticket setupAdminTicket system setup
/ticket createPublicOpen a ticket
/ticket close/claim/transcriptPublicTicket actions
/rankPublicView level & XP
/topPublicLeaderboard
/xpAdminLeveling config
/pollPublicCreate polls
/askPublicAsk KrogieBot (AI)
/helpPublicCommand overview
BetterGhast v3.0 — Home · GitHub · Terms · Privacy