Hi I'm having some issues with a bit of code which I'm getting a type error
which is TypeError: 'bool' object is not iterable Should I be using an if state rather that a for statement?
What I'm trying to achieve is if on_message a message has been pinned for 7 days or more then unpin that message.
Here's what I'm working with:
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!")
Not sure where I'm going wrong here.
In your for loop, message.channel.id == channelid evaluates to a boolean value either True or False. So your for loop becomes either
for message.content in True
or
for message.content in False
The right side of in here must be some iterable. The compiler complains because it isn't.
To suggest a solution to this problem, we need more information about what you are trying to do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With