Python 不和谐。Py不在不和谐中发送我的消息
我想让我的机器人说一行特定的代码,这取决于哪一天。然而,这导致了一些问题,因为机器人甚至没有写任何不一致的东西Python 不和谐。Py不在不和谐中发送我的消息,python,discord.py,Python,Discord.py,我想让我的机器人说一行特定的代码,这取决于哪一天。然而,这导致了一些问题,因为机器人甚至没有写任何不一致的东西 async def schedule(ctx): if x.strftime == "Wednesday": await ctx.send(f""" Today is {x.strftime}. Today is a half day. Today's Schedule: Block 1: 7:25 - 8:
async def schedule(ctx):
if x.strftime == "Wednesday":
await ctx.send(f""" Today is {x.strftime}. Today is a half day.
Today's Schedule:
Block 1: 7:25 - 8:25
Block 2: 8:30 - 9:30
Block 3: 9:35 - 10:35
Block 4: 10:40 - 11:40""")
elif x.strftime == "Monday" or x.strftime == "Tuesday" or x.strftime == "Thursday" or x.strftime == "Friday":
await ctx.send(f""" Today is {x.strftime}. Today is a full day.
Today's Schedule:
Block 1: 7:25 - 8:50
Block 2: 8:55 - 10:15
Block 3: 10:20 - 12:25
Block 4: 12:33 - 1:55""")
elif x.strftime == "Saturday" or x.strftime == "Sunday":
await ctx.send(f"Today is {x.strftime}. No school today.")
在哪里定义了
x
?你有追踪到什么吗?试试我提供的解决方案,看看是否适合你。
from datetime import datetime
@client.command() # Change client to whatever you're using
async def schedule(ctx):
day = datetime.now().strftime("%A")
if day == "Wednesday":
await ctx.send(f"Today is {day}. Today is a half day.\n**Today's Schedule**"
f"Block 1: 7:25 - 8:25\nBlock 2: 8:30 - 9:30\nBlock 3: 9:35 - 10:35\n"
f"Block 4: 10:40 - 11:40")
elif day == "Saturday" or day == "Sunday":
await ctx.send(f"Today is {day}. No school today.")
else:
await ctx.send(f"Today is {day}. Today is a full day.\n**Today's Schedule**\n"
f"Block 1: 7:25 - 8:50\nBlock 2: 8:55 - 10:15\nBlock 3: 10:20 - 12:25\nBlock 4: 12:33 - 1:55")