Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Removing specific "part" in two brackets {} in Python

Let me explain:

               if config == "create":
                       if str(user.id) in submissions:
                           await ctx.send(embed=discord.Embed(title="ERROR", description='you already have a submission!', color=discord.Color.red()))
                           return
                       if len(submission_full) > 2 and len(submission_full) < 100:
                               submissions[str(user.id)] = {}
                               submissions[str(user.id)]["submission"] = submission_full

Basically what I have here is a discordpy submission command that creates a submission and dumps it into a json file. I am currently working on a command that does the same thing but reversed, so it deletes your submission if you want to undo.

My first thought was doing this:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

                if config.lower() in ["delete","remove","undo","cancel"]:
                    await ctx.send(embed=discord.Embed(title="Removing Current Submission..", description="You will no longer have any submissions. You can create a new one at any time!", color=0xFFD700))
                    submissions[str(user.id)] = None

But it simply replaces your submission with "null".

Here is the output in the json file:

{"710826704259645450": null}

Help appreciated!

>Solution :

You want:

        del submissions[str(user.id)]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading