I have made a discord bot that acts as a translator i.e. the user can type '!translate word', and the bot will respond with a translation of that word, based on the values in a JSON file. This works fine.
However, I have some issues with another command which lets the user add new words to the JSON file. When the user does '!add word translation', it adds it to the JSON file fine and I can see it clearly in the file in my IDE, but then when I use the !translate command on the word I just added, the bot does not recognise it. It will recognise it when I terminate the program and run it again though. How do I get my bot to recognise the newly added words straight away? Since I want it to just run 24/7 on Heroku or something, and not have to constantly stop and start the program.
This is the code for the add command:
@client.command()
async def add(ctx, *message):
""" User can add an emoji and its english translation to the dictionary.
At the moment the program needs to be terminated and then restarted for the bot to translate the added words"""
if len(message) != 2:
await ctx.send("Incorrect format. Please try again in the format: !add {name} {emoji} \ne.g. '!add fire