I have a bot written in python. Help me deal with HTTP requests. There is a task: rename the channel on command. But discord has a limit on renaming the channel (2 times in 10 minutes). I need to get a timer in seconds from the API and insert it into a condition (if the timer is greater than 0, then send a message with a timer). I can't figure out where I get this timer from... I tried different urls: https://discord.com/api/v9/applications/*app id*, https://discord.com/api/v9/channels/{ctx.channel.id}, https://discord.com/api/v9/users/*bot id*. In the last url, I found the rate-limits headers, but there was some other timer that didn't exactly show the limit for renaming the channel.
Here's my code:
@bot.command()
async def rename(ctx, *, name):
await ctx.message.delete()
headers={
'authorization': 'Bot *Secret token :)*'
}
response = requests.head(f'*I do not know which link to insert here :(*', headers=headers)
limit = response.headers('X-RateLimit-Reset-After') #I need there to be a timer that shows after how many seconds the bot will be able to rename the channel
if limit == 0:
await ctx.channel.edit(name=f'{name}')
if limit > 0:
await ctx.channel.send(f'Can`t rename. Pls, wait {limit} seconds')