I need to create a button that will create a link to the discord message.
This is implemented in my code like this:
transcript = await chat_exporter.export(tchannel)
transcript_file = discord.File(io.BytesIO(transcript.encode()),
filename=f"transcript-{tchannel.name}_{tchannel.id}.html")
transcript_message = await lchannel.send(file=transcript_file)
tauthor = await bot.fetch_user(int(ticketInfo[1]))
….
transcript_url = ("https://mahto.id/chat-exporter?url="+ transcript_message.attachments[0].url)
But since discord has limited the duration of links, I need to create dynamic links. To do this, I need to add a button after clicking on which a link to view the saved ticket will be generated
Now I have such a code, but it doesn’t work. Please help me find the errors
class MyView(discord.ui.View):
@discord.ui.button(label="Click me!", style=discord.ButtonStyle.primary)
async def button_callback(self, button, interaction):
transcript_message = ctx.transcript_message
transcript_url = ("http://v927477t.beget.tech/chat-exporter/?url="+ transcript_message.attachments[0].url)
view=MyView()
view.add_item(discord.ui.Button(label="URL Button",style=discord.ButtonStyle.link,url=transcript_url))
I tried to run my code, but it doesn’t work
I tried to create a button, but it doesn’t work
Vladislav Glebov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.