`import discord
from discord.ext import commands
from discord.ui import View, Button
import asyncio
def setup(bot):
class MyView(View):
def init(self, bot):
super().init()
self.bot = bot
async def on_button_click(self, button, interaction):
if button.custom_id == "preencher_dados":
await interaction.response.defer()
dm_channel = await interaction.user.create_dm()
await dm_channel.send("???? Aguardando seus dados...")
await self.prompt_data(interaction, dm_channel)
async def prompt_data(self, interaction, dm_channel):
def check(message):
return message.author == interaction.user and message.channel == dm_channel
try:
await dm_channel.send("Digite seu nome, sobrenome e ID separados por vírgula (,). Exemplo: Fulano, de Tal, 8230")
message = await self.bot.wait_for("message", check=check, timeout=60)
if ',' in message.content:
nome, sobrenome, user_id = message.content.split(',')
novo_nome = f'{nome.strip()} {sobrenome.strip()} | {user_id.strip()}'
try:
member = await interaction.guild.fetch_member(interaction.user.id)
if member.guild.me.guild_permissions.change_nickname:
await member.edit(nick=novo_nome)
await dm_channel.send(f"✅ Seu nome foi alterado para {novo_nome}")
await interaction.response.send_message("✅ Dados atualizados com sucesso!")
else:
await dm_channel.send("❌ Desculpe, eu não tenho permissão para alterar seu apelido.")
except Exception as e:
await dm_channel.send(f"❌ Ocorreu um erro: {str(e)}")
else:
await dm_channel.send("❌ Formato inválido. Por favor, siga o formato: Nome, Sobrenome, ID")
except asyncio.TimeoutError:
await dm_channel.send("❌ Tempo esgotado. Por favor, tente novamente.")
@bot.command()
async def create_embed(ctx):
view = MyView(bot)
view.add_item(Button(label="????️ Preencher Dados", custom_id="preencher_dados"))
embed = discord.Embed(
title="???? Preencha seus dados",
description="Clique no botão abaixo para preencher seus dados.",
color=discord.Color.green()
)
message = await ctx.send(embed=embed, view=view)
`
Sure, I can help with that. Here is the translated and corrected code