[Python] Trying to send a debug message whenever my bot is trying to DM a member with their...

Discussão em 'Python' iniciado por Stack, Outubro 1, 2024.

  1. Stack

    Stack Membro Participativo

    I'm trying to send an embed describing the error whenever my bot dm command, but it just goes straight to the error, without sending the embed.

    Here's my code for the error event:

    @client.event
    async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandInvokeError(Forbidden)):
    emb = Embed(title="Error : Forbidden",
    description="Couldn't use the command, probably because you tried to DM someone with their DM's off",
    color=0xFF0000)
    emb.add_image("https://media1.tenor.com/m/5lbcs68aI2MAAAAC/anime-sad.gif")
    await ctx.send(embed=emb)


    and for my dm command :

    @client.tree.command(name="dm", description="DM's someone!", guild=GUILD_ID)
    async def dm(interaction: discord.Interaction, user: discord.Member, message: str):
    em = Embed(title=f"Here's a message from {interaction.user.display_name}!",
    description=message,
    color=0x00FF00)
    em.set_footer(text='Answer them by using /dm !')
    await user.send(embed=em)
    await interaction.response.send_message("DM sent!")


    I'm using discord.py latest update, and python 3.10.8

    Continue reading...

Compartilhe esta Página