I am about to make a Global Chat bot and it works pretty good but since it is in 70 Servers, he really struggles with sending the Messages. At the moment my code to send the messages looks like this:
async def sendallchannel(self, embed):
for channel in fetchedchannel:
try:
await channel.send(embed = embed)
except:
pass
and as I just said, it take about 1 Minute till the Message is send to every Server. Is there a way to send the Messages faster?
the variable fetchedchannel is a list of every channel already fetched, so the Bot don’t need to fetch every Channel one by one when he wants to send a Message
>Solution :
This should be much faster as all coroutines will be ran concurrently :
async def sendallchannel(self, embed):
coroutines = [channel.send(embed=embed) for channel in fetchedchannel]
await asyncio.gather(*coroutines)