I have made a meme command which looks like this
Is there any way to end the interaction on clicking the End Interaction button. Please help me with the end_interaction
function.
Code:
@commands.command(aliases=['m'], description='Posts memes from r/memes')
async def meme(self, ctx):
submissions = await get_memes('memes')
button1 = Button(label='Next Meme', style=discord.ButtonStyle.green)
button2 = Button(label='End Interaction', style=discord.ButtonStyle.red)
async def next_meme(interaction):
if len(submissions) == 0:
await interaction.response.edit_message(content='No more memes available')
return
submissions.pop(0)
embed.title = submissions[0].title
embed.url = submissions[0].url
embed.set_image(url=submissions[0].url)
await interaction.response.edit_message(embed=embed)
async def end_interaction(interaction):
pass
# I have no idea what to do here
view = View()
view.add_item(button1)
view.add_item(button2)
embed = discord.Embed(title=submissions[0].title, url=submissions[0].url, colour=discord.Colour.random())
embed.set_image(url=submissions[0].url)
await ctx.send(embed=embed, view=view)
button1.callback = next_meme
button2.callback = end_interaction