Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to remove role from people with a reaction 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 :: map a list to another list python 
Python :: listas en python 
Python :: raise_for_status() requests 
Python :: numpy random 
Python :: making ckeditor django responsive 
Python :: pickled list 
Python :: how to check if string is in byte formate pythin 
Python :: histogram chart plotly 
Python :: free download django app for windows 10 
Python :: django filter multiple conditions 
Python :: matplotlib histogram frequency labels 
Python :: python merge strings 
Python :: transform image to rgb python 
Python :: make gif from images in python 
Python :: join python documentation 
Python :: #pip install commands 
Python :: rename colums dataframe pandas 
Python :: from django.urls import re_path 
Python :: join tuple to string python 
Python :: fizz buzz in python 
Python :: Adding new column to existing DataFrame in Pandas using concat method 
Python :: how to show installed tkinter fonts 
Python :: Normalize columns in pandas dataframe2 
Python :: how to append to a list in python 
Python :: recursive factorial python 
Python :: django background_task 
Python :: array creation in numpy 
Python :: read xml file in python 
Python :: python set 
Python :: reading from a file in python 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =