Can someone help me how to create meme command like dank memer. Below is the photo of the command i want to make.
enter image description here
>Solution :
This is the meme command I am using now. This is also similar to dank memer.
This is from the library of discord_compoenents. You can refer the docs for using the button
@commands.command(aliases=['me'])
@commands.guild_only()
@commands.cooldown(1, 3, commands.BucketType.user)
async def meme(self,ctx):
serverId = ctx.message.guild.id
def meme_opt():
choices=[1,2]
chosen=random.choice(choices)
if(chosen==1):
'''Post a meme'''
r = requests.get("https://memes.blademaker.tv/api?lang=en")
res = r.json()
title = res["title"]
ups = res["ups"]
# downs = res["downs"]
comments = res['score']
authors=res["author"]
memes = discord.Embed(title=f"{title}",colour=randint(0, 0xffffff))
memes.set_image(url=res["image"])
memes.set_footer(text=f"👍 : {ups} ✍️ : {authors} 💬 : {comments} ")
else:
###################
r=requests.get("https://meme-api.herokuapp.com/gimme")
res=r.json()
title=res["title"]
ups=res["ups"]
author=res["author"]
link=res["postLink"]
memes = discord.Embed(description=f"[{title}]({link})",colour=randint(0, 0xffffff))
memes.set_image(url=res["url"])
memes.set_footer(text=f"👍 : {ups} ✍️ : {author}")
return memes
components = [
[
Button(label='Next meme', style=ButtonStyle.green, custom_id='next'),
Button(label='End interaction', style=ButtonStyle.red, custom_id='exit')
]
]
message = await ctx.send(embed=meme_opt(), components=components)
id=message.id
while True:
try:
interaction = await self.bot.wait_for(
'button_click',
check=lambda inter: inter.message.id == message.id,
timeout=30
)
except asyncio.TimeoutError:
for row in components:
row.disable_components()
return await message.edit(components=components)
if(interaction.author.id==ctx.author.id):
if(interaction.custom_id=="next"):
await interaction.edit_origin(embed=meme_opt(),components=components)
elif(interaction.custom_id=="exit"):
for row in components:
row.disable_components()
message=await ctx.fetch_message(id)
return await interaction.edit_origin(embed=message.embeds[0],components=components)
else:
await interaction.send("Hey! This is not for you!")