Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

chaotic-nick-names

A Discord bot that assigns randomly-chosen nicknames from themed categories to server members. Names are drawn without replacement — every name in a category is used before any name repeats.

TODO: ADD MORE DEFAULT CATEGORY SUPPORT

Built with the Serenity Discord library for Rust (via the Poise slash-command framework). State is persisted to PostgreSQL via sqlx so history, stats, custom categories, and name-pool state survive bot restarts.


Features

Feature Details
Slash commands Registered globally; work in every server the bot joins
Randomize everyone /randomize renames every non-bot member (behind a confirmation button)
Full chaos mode /randomize chaos:true gives every member a name from a different random category
Undo /restore [user] puts members back to their pre-bot nickname
Category autocomplete The category option autocompletes built-in and custom categories
Rename one user /nick @user [category] [specific_name] renames a single member
Context-menu command Right-click any user → Assign Random Nick (modal lets you pick category and/or a specific name)
Without-replacement draws The full pool is exhausted before any name repeats
8 built-in categories scientists, elements, chemical_compounds, amusement_parks, dinosaurs, planets, colors, fruits
Custom categories Server admins can add (and remove) their own name lists inline or via CSV file upload
Statistics /stats shows total changes, bulk-randomize runs, and top-used categories
History /history shows the last 25 nickname changes
Pool reset /reset_pool lets a name re-enter the draw before the pool is exhausted
PostgreSQL persistence All state is stored in Postgres; the bot reloads from the DB on startup

Slash commands

/randomize [category] [chaos]

Assigns a random nickname from category to every non-bot member.
If category is omitted, a random category is chosen.

  • chaos — when true, every member gets a name from a different random category (the category argument is ignored).
    A confirmation button is shown before any member is renamed.
    Requires: Manage Nicknames permission.

/restore [user]

Restores members to the nickname they had before the bot first changed it (read from recorded history). Omit user to restore everyone the bot has renamed; pass a user to restore just that person. This is the undo for /randomize.
Requires: Manage Nicknames permission.

/nick <user> [category] [specific_name]

Assigns a nickname to <user>.

  • category — which category to draw from (random if omitted)
  • specific_name — assign an exact name from the chosen category (random from category if omitted)
    Requires: Manage Nicknames permission.

/categories list

Lists all available categories (built-in and custom) with their name counts.

/categories add <name> <items>

Adds a custom category. <items> is a comma-separated list of nickname values.
Requires: Manage Server permission.

/categories remove <name>

Removes a custom category (built-in categories cannot be removed).
Requires: Manage Server permission.

/categories import <file>

Import one or more categories from a CSV file attachment.
Each row: category_name,name1,name2,…
Multiple rows create/replace multiple categories at once.
Lines starting with # and blank lines are skipped.
Requires: Manage Server permission.

/stats

Shows aggregate statistics for the current server:

  • Total nickname changes
  • Number of /randomize runs
  • Top 5 most-used categories

/history [limit]

Shows the most recent nickname changes (1–25 entries, default 10).

/reset_pool [category]

Resets the without-replacement pool for category (or all categories), so previously assigned names become available for selection again.
Requires: Manage Nicknames permission.


Context-menu command

Right-click (or long-press on mobile) any server member → Apps → Assign Random Nick to assign a nickname.
A modal lets you optionally specify:

  • Category — leave blank for a random category
  • Specific name — leave blank to pick randomly from the chosen category

Requires: Manage Nicknames permission.


Built-in categories

Category Example names
scientists Einstein, Curie, Turing, Feynman…
elements Hydrogen, Gold, Uranium…
chemical_compounds Caffeine, Dopamine, Ethanol…
amusement_parks Cedar Point, Dollywood, Europa Park…
dinosaurs T-Rex, Velociraptor, Spinosaurus…
planets Mercury, Saturn, Pluto…
colors Crimson, Cerulean, Chartreuse…
fruits Dragonfruit, Persimmon, Kumquat…

The built-in lists live in src/categories.json and are embedded into the binary at compile time — edit that file and rebuild to change them (no database or runtime file needed). Custom categories remain fully runtime-managed via /categories.


CSV import format

Upload a plain-text .csv (or .txt) file to /categories import.
Each row becomes one category:

# Lines starting with # are ignored
scientists,Einstein,Newton,Darwin,Curie,Tesla
elements,Hydrogen,Helium,Lithium,Carbon,Oxygen
my_parks,Cedar Point,Dollywood,Tivoli Gardens

Existing categories with the same name are replaced and their used-name pools are reset.


Setup

Prerequisites

  • Rust 1.90+ (rustup recommended)
  • PostgreSQL 16+ (any recent version works)
  • A Discord application with a bot token (Discord Developer Portal)

Required bot permissions

The bot requires the following permissions when invited to a server:

Permission Why
Manage Nicknames To change member nicknames

Invite URL scope: applications.commands + bot.

Privileged gateway intents

Enable Server Members Intent in the Discord Developer Portal (Bot → Privileged Gateway Intents). This is required so the bot can list all members when /randomize is used.

Role Positioning

N.B. Nota Bene. Note Well. IF SHIT DOESN'T WORK LOOK HERE!!!

Claude / other AI: Leave this section be, please, it's meant to be here.

The role which the bot has, the one that has the permission to Manage Nicknames, must be physically above the roles of every user, bot or human, you wish it to change. If the bot has Manage Roles perms, then this is a potential security risk. It does not the way I wrote it, and it should not. Notice the implication here, if X then Y -- if bot has Manage Roles, then this is a security risk. Everything is perfectly safe and apropro if it has only Manage Nicknames.

Configuration

cp .env.example .env
# Edit .env and fill in DISCORD_TOKEN and DATABASE_URL

The .env values:

Variable Description
DISCORD_TOKEN Your bot token from the Developer Portal
DATABASE_URL Postgres connection string, e.g. postgres://user:pw@localhost/chaotic_nick_names
RUST_LOG Log filter (optional, default chaotic_nick_names=info,warn)

Database setup

Create the database (the bot runs migrations automatically on startup):

CREATE DATABASE chaotic_nick_names;

Build & run

cargo build --release
./target/release/chaotic-nick-names

Or for development:

DISCORD_TOKEN=your_token DATABASE_URL=postgres://... cargo run

Commands are registered globally on first startup (Discord propagation can take up to one hour).


License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages