# Buggy code
async def dm(self, ctx: commands.Context, user_id: int, *, message: str):
    """Sends a DM to a user

    This command needs a user id to work.
    To get a user id enable 'developer mode' in Discord's
    settings, 'appearance' tab. Then right click a user
    and copy their id"""
    destination = discord.utils.get(ctx.bot.get_all_members(), id=user_id)
    if destination is None:
        await ctx.send(
            _(
                "Invalid ID or user not found. You can only "
                "send messages to people I share a server "
                "with."
            )
        )
        return

    fake_message = namedtuple("Message", "guild")
    prefixes = await ctx.bot.command_prefix(ctx.bot, fake_message(guild=None))
    prefix = prefixes[0]
    description = _("Owner of {}").format(ctx.bot.user)
    content = _("You can reply to this message with {}contact").format(prefix)
    if await ctx.embed_requested():
        e = discord.Embed(colour=discord.Colour.red(), description=message)

        e.set_footer(text=content)
        if ctx.bot.user.avatar_url:
            e.set_author(name=description, icon_url=ctx.bot.user.avatar_url)
        else:
            e.set_author(name=description)

        try:
            await destination.send(embed=e)
        except discord.HTTPException:
            await ctx.send(
                _("Sorry, I couldn't deliver your message to {}").format(destination)
            )
        else:
            await ctx.send(_("Message delivered to {}").format(destination))
    else:
        response = "{}\nMessage:\n\n{}".format(description, message)
        try:
            await destination.send("{}\n{}".format(box(response), content))
        except discord.HTTPException:
            await ctx.send(
                _("Sorry, I couldn't deliver your message to {}").format(destination)
            )
        else:
            await ctx.send(_("Message delivered to {}").format(destination))


# Traceback (AttributeError)
Traceback (most recent call last):
File "/.../lib/python3.8/site-packages/discord/ext/commands/core.py", line 83, in wrapped
ret = await coro(*args, **kwargs)
File "/.../lib/python3.8/site-packages/redbot/core/core_commands.py", line 1609, in dm
await destination.send(embed=e)
File "/.../lib/python3.8/site-packages/discord/abc.py", line 824, in send
channel = await self._get_channel()
File "/.../lib/python3.8/site-packages/discord/member.py", line 248, in _get_channel
ch = await self.create_dm()
File "/.../lib/python3.8/site-packages/discord/member.py", line 109, in general
return getattr(self._user, x)(*args, **kwargs)
AttributeError: 'ClientUser' object has no attribute 'create_dm'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/.../lib/python3.8/site-packages/discord/ext/commands/bot.py", line 892, in invoke
await ctx.command.invoke(ctx)
File "/.../lib/python3.8/site-packages/discord/ext/commands/core.py", line 797, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/.../lib/python3.8/site-packages/discord/ext/commands/core.py", line 92, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'ClientUser' object has no attribute 'create_dm'

# Fixed code
async def dm(self, ctx: commands.Context, user_id: int, *, message: str):
    """Sends a DM to a user

    This command needs a user id to work.
    To get a user id enable 'developer mode' in Discord's
    settings, 'appearance' tab. Then right click a user
    and copy their id"""
    destination = discord.utils.get(ctx.bot.get_all_members(), id=user_id)
    if destination is None or destination.bot:
        await ctx.send(
            _(
                "Invalid ID, user not found, or user is a bot. "
                "You can only send messages to people I share "
                "a server with."
            )
        )
        return

    fake_message = namedtuple("Message", "guild")
    prefixes = await ctx.bot.command_prefix(ctx.bot, fake_message(guild=None))
    prefix = prefixes[0]
    description = _("Owner of {}").format(ctx.bot.user)
    content = _("You can reply to this message with {}contact").format(prefix)
    if await ctx.embed_requested():
        e = discord.Embed(colour=discord.Colour.red(), description=message)

        e.set_footer(text=content)
        if ctx.bot.user.avatar_url:
            e.set_author(name=description, icon_url=ctx.bot.user.avatar_url)
        else:
            e.set_author(name=description)

        try:
            await destination.send(embed=e)
        except discord.HTTPException:
            await ctx.send(
                _("Sorry, I couldn't deliver your message to {}").format(destination)
            )
        else:
            await ctx.send(_("Message delivered to {}").format(destination))
    else:
        response = "{}\nMessage:\n\n{}".format(description, message)
        try:
            await destination.send("{}\n{}".format(box(response), content))
        except discord.HTTPException:
            await ctx.send(
                _("Sorry, I couldn't deliver your message to {}").format(destination)
            )
        else:
            await ctx.send(_("Message delivered to {}").format(destination))