您好我在尝试添加时间戳时遇到错误。我不断收到错误asyncpg.exceptions.PostgresSyntaxError: syntax error at or near "18"
,这条线end_date = duration + dt.datetime.now(bst) # timestamp
似乎是罪魁祸首,但我不确定为什么会这样。
这是我正在使用的内容:
if time is not None:
conn = await asyncpg.connect(DATABASE_URL)
async with conn.transaction():
await conn.fetch(f"SELECT time FROM blacklist WHERE username={member.id}")
duration = find_date(time)
bst = pytz.timezone('Europe/London')
end_date = duration + dt.datetime.now(bst) # timestamp
fmt_date = end_date.strftime("%#d %b %Y, at %I:%M%p")
await conn.fetch(f"UPDATE blacklist SET time={end_date} WHERE username={member.id}")
await member.add_roles(restricted, reason=f'Restricted role added by {author.name}')
await member.remove_roles(members)
await conn.close()
msg = f"{member} has been restricted until {fmt_date}."
embed = discord.Embed(title="Restricted", description=msg, colour=author.color)
await ctx.send(embed=embed)
return