python - 语法错误 || 不和谐.py || 第 18 行代码
问题描述
我正在创建预售票系统,但我在第 18 行遇到问题,它给了我一个语法错误。请在您的 IDE 中尝试并帮助我
@bot.event
async def on_raw_reaction_add(payload):
if payload.member.id != bot.user.id and payload.emoji== u"\U0001F3AB":
msg_id, channel_id, category_id= bot.ticket_configs[payload.guild_id]
if payload.message_id == msg_id:
guild= bot.get_guild(payload.guild_id)
for category in guild.categories:
if category.id == category_id:
break
channel = guild.get_channel(channel_id)
ticket_num= 1 if len(category.channels) == 0 else int(category.channels.split("-")[-1]) + 1
ticket_channel= await category.create_text_channel(f"Ticket {ticket_num}", topic= f"Channel for ticket number {ticket_num}.", permission_synced= True)
await ticket_channel.set_permissions(payload.member, read_messages= True, send_messages= True)
message= await channel.fetch_message(msg_id)
await message.remove_reaction(payload.emoji, payload.member)
await ticket_channel.send(f"{payload.member.mention} Thank You! for creating this ticket staff will contact you soon. Type **-close** to close the ticket.")
try:
await bot.wait_for("message", check=lamda m: m.channel== ticket_channel and m.author== payload.member and m.content == "-close", timeout= 3600)
except asyncio.TimeoutError:
await ticket_channel.delete()
else:
await ticket_channel.deleted()
解决方案
你有一个错字在线
await bot.wait_for("message", check=lamda m: m.channel== ticket_channel and m.author== payload.member and m.content == "-close", timeout= 3600)
应该是lam b da,即
await bot.wait_for(
"message",
check=lambda m: m.channel == ticket_channel and m.author == payload.member and m.content == "-close",
timeout=3600,
)
推荐阅读
- git - 来自 VSCode 的 Github 提交没有配置文件图标
- javascript - 为什么jQuery的ajax成功方法不起作用?
- javascript - 如何使用 VueJs 阻止文本区域中的某些字符?
- readonly - OpenGL ES 和 Spir-V 中的只读存储缓冲区
- magento - angular 和 magento 的 Nginx 配置
- python - 在 Python 3.7 中创建多行字节字符串
- ruby-on-rails - 耙中止!NameError: uninitialized constant ActiveRecord::VERSION error while using rake db:migrate
- php - 如果给定的是月份php,则获取日期
- laravel - 视图 Laravel 中预定义的冗余值
- php - 搜索查询到数据库无操作