I have this cog blocker that puts a guild id and the command blocked in a .json file. When the command is used, it will check to see if this information is in the .json file, if it is, it will not run the command. Although, I do not know how to make it so it takes out the command or guild id so the command can be used again. Please help!

    @commands.command()
    @has_permissions(administrator=True)
    async def block(self, ctx, cmd: str):
        with open(os.path.dirname(__file__) + f'/json/data.json','r+') as f:
            data=json.load(f)
            if not str(ctx.message.guild.id) in data:
                data.update({str(ctx.message.guild.id): []})
                data[str(ctx.message.guild.id)].append(cmd)
            else:
                if cmd not in data[str(ctx.message.guild.id)]:
                    data[str(ctx.message.guild.id)].append(cmd)
                    await ctx.send(embed=discord.Embed(description=f'{ctx.author.mention} has banned the command **{cmd}**',color=65535))
                else:
                    await ctx.send(embed=discord.Embed(description=f'{ctx.author.mention} **{cmd}** is already banned', color=65535))
            self.write("data", data)

If you can give me the code, that would be greatly appreciated.


Ok so you can remove the guild id simply by

# Do a if id in data.keys() b4 to make sure there wont be a KeyError
with open('json/data.json','r+') as f:  # u don't need the f"" or __file__
    data = json.load(f)
    del data[str(ctx.guild.id)]
    # save json do bomb stuff

Now deleting a specific command

#Load json like the previous snippet
if cmd in data[str(ctx.guild.id)]:
    del data[str(ctx.guild.id)][data[str(ctx.guild.id)].index(cmd)]
    #save json

and its also advisable to use a db instead of json(its very useful for seldom changed data) but if its a small project json would do fine