Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

add role discord .py

member = message.author
var = discord.utils.get(message.guild.roles, name = "role name")
member.add_role(var)
Comment

add role discord .py


from discord.ext import commands
from discord.utils import get

bot = commands.Bot(command_prefix='!')

@bot.command(pass_context=True)
@commands.has_role("Admin") # This must be exactly the name of the appropriate role
async def addrole(ctx):
    member = ctx.message.author
    role = get(member.server.roles, name="Test")
    await bot.add_roles(member, role)

Comment

create a role with discord.py

@client.command(aliases=['make_role'])
@commands.has_permissions(manage_roles=True) # Check if the user executing the command can manage roles
async def create_role(ctx, *, name):
	guild = ctx.guild
	await guild.create_role(name=name)
	await ctx.send(f'Role `{name}` has been created')
Comment

How to create role discord.py

guild = ctx.guild
await guild.create_role(name="role name")
Comment

how to mention a role discord.py

#To mention a role you need the role ID
#Exaple
#you can use ~bot~ or ~client~ it dont matter
@bot.command
async def exaple_test(ctx):
	await ctx.send(f"Role: <@&_your_role_id_here_)>")
Comment

PREVIOUS NEXT
Code Example
Python :: split list python percent 
Python :: django run manage.py from python 
Python :: round float python 
Python :: open file in python 
Python :: circle python programe 
Python :: whitelist the ip address django 
Python :: change xlabel python 
Python :: add two dataframes together 
Python :: Maximize Difference 
Python :: winsound python 
Python :: python iteration 
Python :: pandas get higher value of column 
Python :: backend in python 
Python :: find item in list 
Python :: kivy display pil image 
Python :: python for loop range 
Python :: null in python 
Python :: django float validator 
Python :: block content 
Python :: plot histogram from counts and bin edges 
Python :: sorted string 
Python :: convert pandas data frame to latex file 
Python :: python repr vs str 
Python :: phython to c converter 
Python :: pyqt click through window 
Python :: python increment 
Python :: lower and upper case user input python 
Python :: TypeError: method() takes 1 positional argument but 2 were given 
Python :: while loop with if else 
Python :: dm command in discord.py 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =