I have a question about Python and Json. I am coding a bot for discord using discord py and I wanted to have a config file. In my code, I need to replace a string from a variable located in a Python file.
This is my current code:
#change prefix
@bot.command(pass_context=True)
async def prefix(ctx, newprefix):
with open("config.json", 'a+') as f:
stringified = JSON.stringify(json)
stringified.replace('"prefix" : prefix, "prefix" : newprefix')
await ctx.send("Prefix set to: `{}`. New prefix will be applied after restart.".format(newprefix))
author = ctx.message.author
print(author, "has changed the prefix to: {}".format(newprefix))
and:
{
"nowplaying":"with buttons",
"ownerid":"173442411878416384",
"prefix":"?",
"token":"..."
}
When I enter the command: ?prefix *newprefix*
, there is no output in discord or the terminal, nothing changes. Can anyone show me a way to do this?