Making a Bot: Allowing for command manipulation in the chat

Hey everyone,

I am making a bot in Golang and am using toml files to handle general config files (containing bot names etc) but am stuck on a big picture level how to let users add, delete, and modify commands from the text chat.

Currently, all user commands are stored in one of these toml files, but the process of appending and such seem really janky to me.

I want a user to be able to type "!addcom !help " for example, like Nightbot.

Big picture, what is the best way to achieve this? I was thinking a DB file or something like that.

I have the source code for the bot here:

In a bot I work on, we use either an embedded database (SQLite3) or have an option to let the user use MySQL. So, yes, I would recommend a database for storing your custom/user commands. I would also recommend thinking about how you want them to work in the long run so that you can either design a very generic database table or one that holds information about the command. For example:

  • Having the ability to let a specific user run a user command rather than everyone.
  • How are you storing permissions for commands? Would there be user commands for moderators only, for example? Commands that could be “spammy” that you wouldn’t want brand new users running?

Good luck on your project!


Thanks for the suggestion: using sqlite3 has been an absolute godsend! And the DB remains very small, which is nice.

In your language of choice, have you been able to grab the command db data and turn it into a map? So that the command name (!help) is the key and the response by the bot is the value?

Just want to make sure there isn’t a simpler way before going down that path.

So, we use Rhino (JavaScript) for handling commands and yes; that is stored within an object that mimics a map/hash. That is the easiest way to do it in my mind, lookup the key, get the value, and print (parse) the value however you see fit.

Glad you like SQLite3. I really enjoy it for small database needs and it also scales up fairly well. There are some performance options you can use if it does seem as if it will grow a lot as well.


1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.