dolfies / discord.py-self

A fork of the popular discord.py for user accounts.
https://discordpy-self.rtfd.io/en/latest/
MIT License
680 stars 161 forks source link

Timeout #381

Closed RobbyV2 closed 1 year ago

RobbyV2 commented 1 year ago

Summary

discord.py has bot.timeout(until, reason)

What is the feature request for?

discord.ext.commands

The Problem

Adding a feature to automatically timeout users if the selfbot has permission.

The Ideal Solution

Allowing the bot to timeout, and un-timeout users for a designated reason and amount of time.

The Current Solution

async def timeout_user(*, user_id: int, guild_id: int, until): headers = {"Authorization": f"Bot {bot.http.token}"} url = f"https://discord.com/api/v9/guilds/{guild_id}/members/{user_id}" timeout = (datetime.datetime.utcnow() + datetime.timedelta(minutes=until)).isoformat() json = {'communication_disabled_until': timeout} async with bot.session.patch(url, json=json, headers=headers) as session: if session.status in range(200, 299): return True return False A previous solution of requesting the discord api has been given, however this does not work for selfbots.

Additional Context

No response

dolfies commented 1 year ago

Already exists in the alpha, look at the docs