Вот мой код для событие ошибки:
Код: Выделить всё
@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)
Код: Выделить всё
@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!")
Подробнее здесь: https://stackoverflow.com/questions/790 ... r-with-the