Answers for "create discord py bot delete role"

1

how to delete role discord py rewrite

@client.command(name="delete_role", pass_context=True)
async def delete_role(ctx, role_name):
    #find role object
    role_object = discord.utils.get(ctx.message.guild.roles, name=role_name)
    #delete role
    await role_object.delete()
Posted by: Guest on July-07-2020
0

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
Posted by: Guest on October-08-2021

Python Answers by Framework

Browse Popular Code Answers by Language