Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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

discord.py permissions

@bot.command()
@commands.has_permissions(manage_messages=True)
async def test(ctx):
    await ctx.send('You can manage messages.')
   
# https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions
Comment

PREVIOUS NEXT
Code Example
Python :: python use variable name as variable 
Python :: how to add reaction by message id in discord.py 
Python :: install scrapy on pycharm 
Python :: find array length in python 
Python :: get index of all element in list python 
Python :: Create an array of 10 zeros 
Python :: python beautifulsoup get option tag value 
Python :: how to generate random number in python 
Python :: django channel 
Python :: best ide for python 
Python :: pyspark read from redshift 
Python :: convert float to string python 
Python :: django update field after save 
Python :: pickled list 
Python :: django cleanup 
Python :: how to comment code in python 
Python :: cv2 frame size 
Python :: change markersize in legend matplotlib 
Python :: access column pandas 
Python :: python dataframe calculate difference between columns 
Python :: import module python same directory 
Python :: google assistant in windows 10 
Python :: join tuple to string python 
Python :: python tutorial pdf 
Python :: dict column to be in multiple columns python 
Python :: create requirements file and load it in new envirnment. 
Python :: pandas how to drop rows with extreme values in a single column 
Python :: django save object in view 
Python :: downgrade python version windows 
Python :: split coumn of df into multiple dynamic columns 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =