Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to remove role discord bot python

#you have to edit some parts of this code
import discord

#this is just another way to say @client.event 
class MyClient(discord.Client):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.target_message_id = (Your message id)

    async def on_ready(self):
        print('Running...')
    #Reaction added
    async def on_raw_reaction_add(self, payload):


        if payload.message_id != self.target_message_id:
            return

        guild = client.get_guild(payload.guild_id)


        if payload.emoji.name == '(Your emoji)':
            role = discord.utils.get(guild.roles, name='<Your role>')
            await payload.member.add_roles(role)

    #Reaction removed
    async def on_raw_reaction_remove(self, payload):


        if payload.message_id != self.target_message_id:
            return

        guild = client.get_guild(payload.guild_id)
        member = guild.get_member(payload.user_id)


        if payload.emoji.name == '(Your emoji)':
            role = discord.utils.get(guild.roles, name='<Your role>')
            await member.remove_roles(role)


intents = discord.Intents.default()
intents.members = True

client = MyClient(intents=intents)
client.run('<Your token>')
#give this a thumbs up if it helped you
Comment

PREVIOUS NEXT
Code Example
Python :: The datetime and django.utils.timezone modules are available, so you can do e.g. timezone.now 
Python :: python convert b string to dict 
Python :: python sort an array 
Python :: how to check a string is empty in python 
Python :: Display an image over another image at a particular co-ordinates in openCV 
Python :: python solve linear equation system 
Python :: soustraire deux listes python 
Python :: django cleanup 
Python :: edit models in django admin 
Python :: Disctionary to Array 
Python :: python is not clickable at point (434, 682). Other element would receive the click: 
Python :: how to find length of list python 
Python :: python dict access 
Python :: access column pandas 
Python :: django authenticate with email 
Python :: simple seaborn heatmap 
Python :: EOFError: EOF when reading a line 
Python :: remove empty string from list python single line 
Python :: poerty python macos 
Python :: fizz buzz 
Python :: py function 
Python :: find & replace in csv file 
Python :: python to linux executable 
Python :: head first python by paul barry pdf 
Python :: include in flask 
Python :: check space in string python 
Python :: compare lists element wise python 
Python :: raw string python 
Python :: relative text size put text cv2 
Python :: pandas bins dummy 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =