Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to limit a command to a permission in discord.py

# Make sure you don't have a command called "commands"
@client.command() # As usual
@commands.has_permissions(administrator=True) # Making sure the person executing the command has the permissions
async def foo(ctx):
	await ctx.send("Hello")
    #ect
Comment

discord.py how to use permissions

from discord import Member
from discord.ext.commands import has_permissions, MissingPermissions

@bot.command(name="kick", pass_context=True)
@has_permissions(manage_roles=True, ban_members=True)
async def _kick(ctx, member: Member):
    await bot.kick(member)

@_kick.error
async def kick_error(error, ctx):
    if isinstance(error, MissingPermissions):
        text = "Sorry {}, you do not have permissions to do that!".format(ctx.message.author)
        await bot.send_message(ctx.message.channel, text)
Comment

PREVIOUS NEXT
Code Example
Python :: epoch to datetime python 
Python :: change the current working directory in python 
Python :: flask secret key generator 
Python :: tensorflow history plot 
Python :: open image in numpy 
Python :: rotate x label 90 degrees seaborn 
Python :: import status in django rest framework 
Python :: python filter array 
Python :: How to get random int between two numbers python 
Python :: python flask query params 
Python :: open image from link python 
Python :: jupyter notebook dark theme 
Python :: find table with class beautifulsoup 
Python :: how to save matplotlib figure to png 
Python :: pandas group by month 
Python :: how to get the current position of mouse on screen using python 
Python :: loop on dataframe lines python 
Python :: print type of exception python 
Python :: virtual environment mac 
Python :: how to permanently store data in python 
Python :: ggplot2 histogram 
Python :: prettytable python 
Python :: how to draw image in tkinter 
Python :: python read csv 
Python :: python get file extension from path 
Python :: list files in directory python 
Python :: python print in color 
Python :: python import from other folder outside folder 
Python :: tesseract.exe python 
Python :: read json file python utf8 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =