Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

store command in discord.py

#create a json file (example: store.json)
@bot.command()
@commands.has_permissions(administrator=True)
async def store(ctx):
    with open('store.json') as json_file:
        data = json.load(json_file)
        store = {"channel_id" : ctx.channel.id, "guild_id" : ctx.guild.id}
      
        data.append(store)
    with open('store.json', 'w') as f:
        json.dump(data, f, indent=4)
Comment

PREVIOUS NEXT
Code Example
Python :: normalized histogram pandas 
Python :: django delete table data 
Python :: python open file check error 
Python :: python remove everything except numbers from string 
Python :: if statement python 
Python :: python remove first element of array 
Python :: create an array filled with 0 
Python :: python load a txt file and assign a variable 
Python :: python download images from unsplash 
Python :: return all values in a list python 
Python :: python replace in string 
Python :: how to omit days pandas datetime 
Python :: histogram python 
Python :: dataFrame changed by function 
Python :: how to put my graph in tkinter interface 
Python :: update in django orm 
Python :: txt to image python 
Python :: How To Remove Elements From a Set using pop() function in python 
Python :: python get bits from byte 
Python :: upload file django 
Python :: python binary tree search 
Python :: python check if string contains one of characters list 
Python :: generative art python 
Python :: How to retrieve previous messages with discord.py 
Python :: extract decimal number from string python 
Python :: controlling the mouse with pynput 
Python :: string remove suffix python 
Python :: Python Join Lists 
Python :: pandas rearrange rows based on datetime index 
Python :: python get pattern from string 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =