A Discord bot that is nothing but Jev decisions
Jeff is a Discord bot built with botbox where every feature is a typed question to Jev, the TypeSafe model that gives back a probability for each answer instead of writing text. There are already a few Jev moderation bots that catch spam and scams so Jeff doesn't do that, instead it is the server's judgment for everything else, it settles debates, ranks lists people give it, tags new forum posts with the forum's own tags, answers questions that are already in the FAQ, keeps track of questions in help channels that nobody answered, plays oracle for tabletop games and runs a party game where everyone guesses the odds. Each of those is one request with a handful of questions and code owns every threshold. It may not be perfect but it's better than nothing.
Not affiliated with TypeSafe or Discord. You need a Discord bot token and a TypeSafe api key, or add the hosted one instead.
The hosted Jeff lives at https://jeff.saembit.com, add it with https://jeff.saembit.com/add and turn plugins on and off from the site, no token or api key needed. Try it before adding it in the demo server, https://discord.gg/ZJ5pyhmFuS. Free servers get a daily cap per plugin, the dashboard shows how much is used.
/settle a b question asks Jev which of a or b is the better answer to the question and posts the pick with the probability of each and the confidence.
/rank opens a modal, items one per line and criteria one question per line, then asks one score per item per criterion in a single request, averages them in code on a 0 to 4 scale and posts the ranked list.
/autotag true or false, run inside a forum or one of its posts, turns tagging on for that forum. When a post is made Jeff asks which of the forum's tags fits, with a none option, and applies the tag when the probability is 60% or more. /autotag-status lists the forums.
/watch true or false marks the current channel as a help channel. Every message there long enough to be a question is checked in one request for two things, is it a question at all and does a FAQ entry ask the same thing. When a FAQ entry matches Jeff replies with the answer, otherwise the question is remembered and a sweep every ten minutes reads the replies after it and asks if any of them answered it. /unanswered lists the ones still waiting with jump links.
/faq-add opens a modal for a question and answer, /faq-list numbers them, /faq-remove number drops one. These need Manage Server, same as /autotag and /watch.
/oracle question asks a yes or no about the scene, with an optional context and a likelihood from very unlikely to very likely that moves the odds, then rolls against them so it can say yes, no, or an exceptional yes and or no and. /ruling situation asks whether the rules of the server's game allow something, /react npc action picks how a character reacts from hostile to friendly with the odds of each, and /dc action gives a difficulty class from 5 to 30. The game is a plugin setting, D&D 5e by default, and roll can be turned off for the likelier answer every time.
/odds question starts a round, everyone presses Guess and types how likely a yes is from 0 to 100, and when the round ends Jeff reveals the odds he gave and who was closest, winners get a point on the server's board. /odds-board shows the top of it. The round length and the board size are plugin settings.
/plugins lists the plugins, judge for /settle and /rank, sorter for tagging, helper for the FAQ and watched channels, oracle for the tabletop commands and odds for the game, whether each one is on in the server and its settings. /plugin-toggle name true or false turns one on or off and /plugin-set name key value changes a setting such as helper question_threshold 0.8, both need Manage Server. Commands of a plugin that is off tell the user it's off instead of running.
The generated /help, /sync, /status, /uptime, /set-prefix and the cog reload commands from botbox are there too.
git clone https://github.com/saembit/jeff-bot
cd jeff-bot
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .envFill in DISCORD_TOKEN, DISCORD_GUILD and TYPESAFE_API_KEY in .env then run it with ./run.sh or botbox run. The bot needs the message content intent turned on in the developer portal for /watch to see messages, and Manage Threads in any forum you turn /autotag on in.
Per server settings and the open questions live in data/.json, the tagged forums, the FAQ entries, the watched channels, the last fifty questions, the scoreboards and the plugin switches and settings. JEFF_DATA_DIR moves that folder. The thresholds are plugin settings changed with /plugin-set, 60% for a tag, 70% for a question and a FAQ match, 60% for answered, and the rank limits of 15 items and 5 criteria are there too.
Each feature cog declares a Plugin at the top with its name, description, tier, how much Jev it uses and its settings, and registers it in src/utils/plugins.py. Commands get the gate.require check from src/utils/gate.py and listeners ask plugins.is_enabled, so a new cog made with botbox add only needs a manifest and the check to show up in /plugins. plugins.schema gives a manifest as json for anything that wants to build a settings form from it. The store in src/utils/store.py is a backend with async load and save that can be swapped with store.set_backend, such as Postgres instead of the json files, and jev.set_observer gets one event per Jev request with the guild, plugin, action, latency, tokens and error, that is how the hosted version logs usage.
pip install -r requirements-dev.txt
pytestThe question packs in src/utils/decisions.py and the store in src/utils/store.py are plain functions with no discord in them so the tests run without a token or an api key, and the client in src/utils/jev.py is tested against a fake session. The cogs were generated with botbox add and then filled in, so botbox config sync still reads them.
- Add the image
- Right click a message, Apps, Check claim, verify it against the thread it is in
- A reaction cog that picks one emoji from a fixed set for a message
- Batch the sweep so one request checks several questions