Repository: Cog-Creators/Red-DiscordBot

Issue:
Warning bot's user causes AttributeError when attempting to send DM
#### Command name

`[p]warn`

#### What cog is this command from?

Warnings

#### What were you expecting to happen?

A graceful error when trying to warn the bot invoking the warn command.

> This does not throw an Exception when warning another bot user, just the invoking bot

#### What actually happened?

```py
Traceback (most recent call last):
  File "a:\projects\alfred\venv\lib\site-packages\discord\ext\commands\core.py", line 83, in wrapped
    ret = await coro(*args, **kwargs)
  File "a:\projects\alfred\venv\lib\site-packages\redbot\cogs\warnings\warnings.py", line 378, in warn
    await user.send(
  File "a:\projects\alfred\venv\lib\site-packages\discord\abc.py", line 824, in send
    channel = await self._get_channel()
  File "a:\projects\alfred\venv\lib\site-packages\discord\member.py", line 248, in _get_channel
    ch = await self.create_dm()
  File "a:\projects\alfred\venv\lib\site-packages\discord\member.py", line 109, in general
    return getattr(self._user, x)(*args, **kwargs)
AttributeError: 'ClientUser' object has no attribute 'create_dm'
```

#### How can we reproduce this issue?

1) Load warnings
2) Warn the bot running the command

Warning bot's user causes AttributeError when attempting to send DM
#### Command name

`[p]warn`

#### What cog is this command from?

Warnings

#### What were you expecting to happen?

A graceful error when trying to warn the bot invoking the warn command.

> This does not throw an Exception when warning another bot user, just the invoking bot

#### What actually happened?

```py
Traceback (most recent call last):
  File "a:\projects\alfred\venv\lib\site-packages\discord\ext\commands\core.py", line 83, in wrapped
    ret = await coro(*args, **kwargs)
  File "a:\projects\alfred\venv\lib\site-packages\redbot\cogs\warnings\warnings.py", line 378, in warn
    await user.send(
  File "a:\projects\alfred\venv\lib\site-packages\discord\abc.py", line 824, in send
    channel = await self._get_channel()
  File "a:\projects\alfred\venv\lib\site-packages\discord\member.py", line 248, in _get_channel
    ch = await self.create_dm()
  File "a:\projects\alfred\venv\lib\site-packages\discord\member.py", line 109, in general
    return getattr(self._user, x)(*args, **kwargs)
AttributeError: 'ClientUser' object has no attribute 'create_dm'
```

#### How can we reproduce this issue?

1) Load warnings
2) Warn the bot running the command



Discussion:
imo, we should just disallow warning bots as there's not really point in warning a computer :P
imo, we should just disallow warning bots as there's not really point in warning a computer :P

Resolving patch:
diff --git a/redbot/cogs/warnings/warnings.py b/redbot/cogs/warnings/warnings.py
--- a/redbot/cogs/warnings/warnings.py
+++ b/redbot/cogs/warnings/warnings.py
@@ -323,6 +323,9 @@ async def warn(
         if user == ctx.author:
             await ctx.send(_("You cannot warn yourself."))
             return
+        if user.bot:
+            await ctx.send(_("You cannot warn other bots."))
+            return
         custom_allowed = await self.config.guild(ctx.guild).allow_custom_reasons()
         guild_settings = self.config.guild(ctx.guild)
         reason_type = None


Test patch: