I have been building a discord bot for some time. Currently tring to timeout users if they react with the wrong emoji. My discord bot gives me an error when i try to timeout user via reaction.
import random
import discord
from datetime import timedelta
intents = discord.Intents.default()
intents.message_content = True
intents.members = True
intents.dm_messages = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print(f'Logged in as {client.user}')
@client.event
async def on_message(message):
if message.content.startswith('test'):
embed=discord.Embed(color=0x00000)
embed.add_field(name="test", value="test", inline=False)
msg=await message.channel.send("testmsg",embed=embed)
await msg.add_reaction("🃏")
@client.event
async def on_reaction_add(reaction, user):
embeds = reaction.message.embeds
embed = embeds[0]
if reaction.emoji == "🃏" and not user.bot:
await user.timeout(until=timedelta(minutes=10),reason="lol")
await reaction.remove(user)
client.run("token")
the error I get is the following
TypeError: Member.timeout() got some positional-only arguments passed as keyword arguments: 'until'
Basically instead of this
await user.timeout(until=timedelta(minutes=10),reason="lol")
Do this
await user.timeout(timedelta(minutes=10),reason="lol")
Positional-only arguments mean that you only pass your value as an argument not keyword with a value as an argument.
See here for some dense reading.
See here for a video on the subject.
Hope that helps.