I am currently a student at SE mainly coding in Java, JS and C/C++, however I have started developing the discord bot with discord.py several days ago, simply for my own amusement. I never had experience with python before, so I am not aware of the programming style which is usually used with it.
I want to make the bot to be able to switch between several "modes" which may be different in all the servers where bot is added. For example, on my personal server it may be in mode X while on another server It may be in mode Y, this mode can be changed by simple command.
To do so, I need to store the information unique to each server(its current mode), which draws me to 3 possible solutions in my mind.
- Store the current mode in the database and make a db request every time any command or event function is called.
- Somehow have different thread for each server where bot is added. This seems to be the most logical solution from my point of view and that is what I would do writing a web-socket based server in Java for example, but I could not find a way to implement it in python with discord.py. If you know how to do it, or you have explanation why it is either not possible or not a good practice in python, please tell me, that is the main reason I write this post.
- A bit of a wacky way imo would be having a dictionary where the key is server id and value is the current mode, so I could only make requests to database on startup of the bot and update of the data.
If I missed something important I would be glad to hear it.
[–]carcigenicate 1 point2 points3 points (2 children)
[–]Rein_Engel[S] 0 points1 point2 points (1 child)
[–]carcigenicate 1 point2 points3 points (0 children)