0

I have made a discord bot in python which makes use of databases to store channel ids where my bot is running. I have a command which allows me to add/remove items from this database, however, it will not actually update the database unless if I reboot the bot. For reference, this bot is written in discord.py and is written on repl.it. This is all I have code-wise, so far:

db['channel_ids'] = channel_ids #just to show which database I want to reference

@client.command(name = 'update_database')
async def update_database():
# want this function to simply make the database update/reload, if this is at all possible.

To add more information, I have a command which allows me to see all of the channel id's which my bot is running in. However, as mentioned, the list it returns may be outdated if I have added/removed some channel ids and not yet rebooted the bot. All I want is a way to get the database to update without having to reboot the bot. Thanks all.

Javkxx
  • 1
  • 1
    Your question is quite unclear... I assume your load the channel IDs on bot startup? If so, just reload the channel IDs whenever you update the database (or modify your local state directly) – Lukas Thaler Dec 14 '21 at 10:52
  • Yes they do load on startup, however, in order to reload them, I must restart the bot. I am looking for a way to reload the database without having to reboot the bot. – Javkxx Dec 20 '21 at 07:35
  • And why exactly can't you just put the code you use to load them on startup into the `update_database()` function? – Lukas Thaler Dec 20 '21 at 07:39

0 Answers0