H
H
HypeEditor2021-11-01 16:29:42
Python
HypeEditor, 2021-11-01 16:29:42

TypeError: 'TextChannel' object is not iterable?

I wrote a message parser for a bot in the discord. You need to get the channel id from the database (sql3) and get the channel itself through self.bot.get_channel(). But at the output I get the following error: The code itself (the database is open, it gets it without problems!):
TypeError: 'TextChannel' object is not iterable

@tasks.loop(hours = 1, reconnect = True)
    async def get_messages(self):
    """ Porting con.CM_COUNT messages to database. """

        system.execute("SELECT codes_id FROM system")
        channel_id = system.fetchone()[0]
        system.close()
        channel = self.bot.get_channel(channel_id)
        for message in channel:

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-11-01
@HypeEditor

for message in channel:
Suddenly, you can't do that. Smoke the history() method .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question