I am making a bot in discord.py and have a fully working meme command using asyncpraw (praw did not work). But it takes a lot of time around 8-10 seconds for the meme to appear. Is there any way to reduce the time? Here is the code :-
@client.command(aliases=['memes'])
async def meme(ctx):
subreddit = await reddit.subreddit("memes")
all_subs = []
top = subreddit.top(limit = 200)
async for submission in top:
all_subs.append(submission)
random_sub = random.choice(all_subs)
name = random_sub.title
url = random_sub.url
ups = random_sub.score
link = random_sub.permalink
comments = random_sub.num_comments
embed = discord.Embed(title=name,url=f"https://reddit.com{link}", color=ctx.author.color)
embed.set_image(url=url)
embed.set_footer(text = f"{ups} {comments}")
await ctx.send(embed=embed)