Skip to content

Commit f764526

Browse files
committed
Add timeout example
1 parent 7353452 commit f764526

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

examples/timeout.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import datetime
2+
3+
import discord
4+
5+
bot = discord.Bot()
6+
7+
8+
@bot.command()
9+
async def timeout(ctx, member: discord.Member, minutes: int):
10+
"""Set timeout on a member"""
11+
12+
now = datetime.datetime.now() # get current time
13+
until = now + datetime.timedelta(minutes=minutes) # add the duration
14+
await member.timeout(until=until)
15+
await ctx.respond(f"Member timed out for {minutes} minutes.")
16+
17+
18+
bot.run("TOKEN")

0 commit comments

Comments
 (0)