How can I send the user to a timeout? #8232
-
I make my bot for moderation and not only. And I want to make a timeout instead of issuing a mute, how can I implement this on the developer version? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Timing out a MemberImplementing a timeout on a
Small Example@bot.command()
@commands.has_permissions(moderate_members=True)
async def timeout(ctx: commands.Context, member: discord.Member):
await member.timeout(datetime.timedelta(hours=1), reason=f"Requested by {ctx.author}")
await ctx.send(f"I've timed out {member.mention} for 1 hour.") How do I remove the timeout on the Member?Call either of the two methods above with the I need some more help?Feel free to join the discord.py Discord server for faster help in one of the help channels :) |
Beta Was this translation helpful? Give feedback.
-
Here you go! @bot.command()
async def mute(ctx, member : discord.Member, *, reason):
s = ctx.author
if not s.guild_permissions.administrator:
return await ctx.channel.send(f'<@{s.id}> you don't have permissions!')
if reason == None:
await member.timeout(datetime.timedelta(hours=1), reason="No reason was given.")
await member.timeout(datetime.timedelta(hours=1), reason=reason)
await ctx.send(f'Violator {member.mention}, was timeouted.') |
Beta Was this translation helpful? Give feedback.
Timing out a Member
Implementing a timeout on a
discord.Member
is pretty simple. Please note you can not timeout an instance ofdiscord.User
because users are not guild specific. You have two methods you can call to timeout the member.timed_out_until
parameter.Small Example
How do I remove the timeout on the Member?
Call either of the two methods above with the
until
…