I'm not an expert with async stuff but I don't understand this. I'm using TwitterAPI to fetch the Twitter API stream endpoint for new posts. I set the channel and it should listen for new posts and it works fine. But why can't I use my foo command while the set_channel function is running? I thought it's async... I'm probably understanding something completely wrong, whatever. Help would be appreciated.
@bot.command()
async def set_channel(ctx):
while True:
try:
iterator = api.request(
'statuses/filter', {'follow': user_ids}).get_iterator()
for item in iterator:
if 'text' in item:
await ctx.channel.send(item['text'])
elif 'disconnect' in item:
event = item['disconnect']
if event['code'] in [2, 5, 6, 7]:
raise Exception(event['reason'])
else:
break
except TwitterRequestError as e:
if e.status_code < 500:
raise
else:
pass
except TwitterConnectionError:
pass
@bot.command()
async def foo(ctx):
await ctx.channel.send("bar")
```