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 :: python smtp email 
Python :: django create token for user 
Python :: Python loop to run for certain amount of seconds 
Python :: python mysqldb 
Python :: merge dataframe 
Python :: get list of files in directory python 
Python :: Creating a list with list comprehensions 
Python :: How can I install XGBoost package in python on Windows 
Python :: enumerate python 
Python :: length of a matrix in python 
Python :: django link home page 
Python :: escape brackets in f string 
Python :: sqlite3 python parameterized query 
Python :: python csv 
Python :: how to use print function in python 
Python :: merge on row number python 
Python :: extract url from page python 
Python :: code to find the shape of the 2d list in python 
Python :: pandas iloc select certain columns 
Python :: pi in python math 
Python :: what is join use for in python 
Python :: python obtain data from pandas dataframe without index name 
Python :: python jokes 
Python :: how to check which submit button is clicked in flask wtf 
Python :: how to convert a byte array to string in python 
Python :: python get directory of current script file 
Python :: pangram function 
Python :: root template 
Python :: cut part of video ffmpeg 
Python :: pathlib get extension 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =