嗨,我有一些问题的代码,我得到一个类型错误
哪个是TypeError: 'bool' object is not iterable
我应该使用if
状态而不是for
语句?在
我要实现的是,如果一条消息被固定了7天或更长时间,那么就取消固定该消息。在
我的工作是:
async def on_message(self, message):
"""Listen for a message then unpin any other messages older than 7 days"""
server = message.server
channelid = '490899209067823135'
limit_date = datetime.now() - timedelta(days=7)
if server:
for message.content in message.channel.id == channelid:
if limit_date:
try:
await self.bot.unpin_message(message)
except discord.Forbidden:
print("No permissions to do that!")
我不知道我哪里出错了。在
问题是:
==正在检查是否mess.age.频道.id和channelid相等,因此您的statemnts有效地
^{pr2}$或者
for循环遍历列表或类似结构中的每个元素,因此不能在“in”后面使用布尔值
我猜你们是不是想把channelid分配给消息.channel.id,然后循环。e、 g
for message.content in message.channel.id == channelid:
也许你是想
在for循环中,}的布尔值。所以你的
message.channel.id == channelid
的计算结果为True
或{for
循环变成了或者
^{pr2}$此处
in
的右侧必须是某个iterable。编译器会抱怨,因为它不是为了提出这个问题的解决方案,我们需要更多关于您正在尝试做什么的信息。在
相关问题 更多 >
编程相关推荐