Boldly going where hundreds have gone before.
This bot contains
- a vectorstore that texts can be saved, loaded, cleared, and have texts added to it.
- support for either printing the vectorstore's raw messages, or passing them to an AI to stitch the messages into a (hopefully-)coherent answer.
- optional caching for exact and similar queries, that can also be saved/loaded/cleared if desired.
- an optional global cooldown.
- the ability for elevated users to request existing messages be added to the vectorstore, pending the original author's approval.
- the ability to block/unblock specific users from interacting with the bot.
- the ability to trust/distrust specific users with elevated commands.
- the ability for users to voluntarily waive/reinvoke the need to ask for their approval prior to adding their messages to the vectorstore.
- the ability to save/load/clear pending vectorstore addition requests and pending waivers.
- Visit Discord's Developer Portal, create a bot, and enable Message Content Intent for it. When invited to servers, the bot must have
Send message,Read message history, andManage reactionspermissions. Copy and save its bot token. - Optional: Visit Groq and create an API key.
- Install Python 3.10 or above alongside its pip package manager.
- Clone or download+extract this repository.
- Open a terminal of your choice and install the required libraries:
pip install -r "[your/path/to/]requirements.txt" -U- Open Settings.py in your editor of choice, and adjust the bot's settings as desired. You can also alter some of the bot's printed messages in Translations.py if desired.
- Launch the bot. If no Groq API key is provided, the bot will solely print the most relevant messages from the vectorstore when queried.
py "[your/path/to/]Main.py" "[Discord bot token]" "[Groq API key (optional)]"This bot is primarily interacted with via slash commands or pinging it.
[/ask or ping the bot] [query]: Looks up and generates an answer for the provided query./help [command (optional)]: Prints the bot's purpose and list of commands, or a single command if one is specified./ping: Returns the bot's latency.[ping the bot] permit: Adds oneself to the permitting group, allowing trusted users to add any of their messages to the vectorstore without having to individually request permission./revoke: Removes oneself from the permitting group, revoking the permission to trusted users granted bypermit./getsize [Blocked Group|Cache|Permitting Group|Permitting Requests|Trusted Group|Vectorstore|Vectorstore Requests]: Returns the number of entries in the provided group/cache/requests list/vectorstore./contains [Blocked Group|Permitting Group|Trusted Group] [user ID (optional)]: Returns whether the provided group contains the command executor, or the provided user if one is specified.
/add [Blocked Group|Trusted Group|Vectorstore] [user ID/message URL]: Directly adds the provided user ID, to the provided group, or requests to add the linked message to the provided vectorstore./clear [All|Blocked Group|Cache|Permitting Group|Permitting Requests|Trusted Group|Vectorstore Requests]: Clears the provided group/cache/requests list/vectorstore, respectively./remove [Blocked Group|Trusted Group] [user ID]: Removes the provided user from the provided group.
/save [All|Blocked Group|Cache|Permitting Group|Permitting Requests|Trusted Group|Vectorstore|Vectorstore Requests] [filepath (optional)]: Saves the provided group/cache/requests list/vectorstore to their last-used filepath, or the provided filepath if specified./load [All|Blocked Group|Cache|Permitting Group|Permitting Requests|Trusted Group|Vectorstore|Vectorstore Requests] [filepath (optional)]: Loads the provided group/cache/requests list/vectorstore from their last-used filepath, or the provided filepath if specified.
For messages sent after the bot is added, trusted users can request to add an existing message to the vectorstore by adding the DISCORD_REQUEST_ADDITION_EMOJI reaction specified in Settings.py. This requires the original author's approval unless the requester is the original author, or the author has voluntarily added himself/herself to the permitting group.
A current limitation is that the bot cannot detect reactions on messages sent prior to the bot last coming online. For those messages, use /add Vectorstore [URL] instead.
For the original code of this bot, much of it was adapted from a similar project I had worked on alongside six other people. All rights to unmodified corresponding pieces of code belong to their original authors. However, the code has also been substantially expanded since then.
Thank you to Fanda857, Meox, Opal, and Tomlacko for providing insights and feedback. Thank you also to Kris, Pokeruto898, and xVoid879 for discovering bugs in the program.
Pull requests or issue filings are welcome.