S
S
Sunter2021-07-16 20:52:11
Python
Sunter, 2021-07-16 20:52:11

How to remove a role from a user after time expires?

async def ping(ctx):
     role = ctx.guild.get_role(863103946063478824) 
     await ctx.author.add_roles(role, reason=None)

There is a code that issues a role.
How to remove a role from a user after 5 minutes?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Endora Blackwell, 2021-07-16
@Sunter

Try like this

import asyncio

async def ping(ctx):
    role = ctx.guild.get_role(863103946063478824) 
    await ctx.author.add_roles(role, reason=None)
    await asyncio.sleep(300)
    await ctx.author.remove_roles(role, reason=None)

A
alfss, 2021-07-16
@alfss

https://discordpy.readthedocs.io/en/stable/api.htm...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question