We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[V3 ModLog] Error in command "case"
# Command bugs


#### Command name

[p]case

#### What cog is this command from?

ModLog

#### What were you expecting to happen?

To show me information about a case.


#### What actually happened?
I get this error:
![image](https://user-images.githubusercontent.com/30272172/43678766-a4a40388-97d6-11e8-90c7-d48ae2c54239.png)



#### How can we reproduce this issue?

1. Have a modlog with cases.
2. Do [p]case


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `redbot/cogs/modlog/modlog.py`
Content:
```
1 import discord
2 
3 from redbot.core import checks, modlog, commands
4 from redbot.core.bot import Red
5 from redbot.core.i18n import Translator, cog_i18n
6 from redbot.core.utils.chat_formatting import box
7 
8 _ = Translator("ModLog", __file__)
9 
10 
11 @cog_i18n(_)
12 class ModLog:
13     """Log for mod actions"""
14 
15     def __init__(self, bot: Red):
16         self.bot = bot
17 
18     @commands.group()
19     @checks.guildowner_or_permissions(administrator=True)
20     async def modlogset(self, ctx: commands.Context):
21         """Settings for the mod log"""
22         pass
23 
24     @modlogset.command()
25     @commands.guild_only()
26     async def modlog(self, ctx: commands.Context, channel: discord.TextChannel = None):
27         """Sets a channel as mod log
28 
29         Leaving the channel parameter empty will deactivate it"""
30         guild = ctx.guild
31         if channel:
32             if channel.permissions_for(guild.me).send_messages:
33                 await modlog.set_modlog_channel(guild, channel)
34                 await ctx.send(_("Mod events will be sent to {}").format(channel.mention))
35             else:
36                 await ctx.send(
37                     _("I do not have permissions to send messages in {}!").format(channel.mention)
38                 )
39         else:
40             try:
41                 await modlog.get_modlog_channel(guild)
42             except RuntimeError:
43                 await ctx.send_help()
44             else:
45                 await modlog.set_modlog_channel(guild, None)
46                 await ctx.send(_("Mod log deactivated."))
47 
48     @modlogset.command(name="cases")
49     @commands.guild_only()
50     async def set_cases(self, ctx: commands.Context, action: str = None):
51         """Enables or disables case creation for each type of mod action"""
52         guild = ctx.guild
53 
54         if action is None:  # No args given
55             casetypes = await modlog.get_all_casetypes(guild)
56             await ctx.send_help()
57             title = _("Current settings:")
58             msg = ""
59             for ct in casetypes:
60                 enabled = await ct.is_enabled()
61                 value = "enabled" if enabled else "disabled"
62                 msg += "%s : %s\n" % (ct.name, value)
63 
64             msg = title + "\n" + box(msg)
65             await ctx.send(msg)
66             return
67         casetype = await modlog.get_casetype(action, guild)
68         if not casetype:
69             await ctx.send(_("That action is not registered"))
70         else:
71 
72             enabled = await casetype.is_enabled()
73             await casetype.set_enabled(True if not enabled else False)
74 
75             msg = _("Case creation for {} actions is now {}.").format(
76                 action, "enabled" if not enabled else "disabled"
77             )
78             await ctx.send(msg)
79 
80     @modlogset.command()
81     @commands.guild_only()
82     async def resetcases(self, ctx: commands.Context):
83         """Resets modlog's cases"""
84         guild = ctx.guild
85         await modlog.reset_cases(guild)
86         await ctx.send(_("Cases have been reset."))
87 
88     @commands.command()
89     @commands.guild_only()
90     async def case(self, ctx: commands.Context, number: int):
91         """Shows the specified case"""
92         try:
93             case = await modlog.get_case(number, ctx.guild, self.bot)
94         except RuntimeError:
95             await ctx.send(_("That case does not exist for that server"))
96             return
97         else:
98             await ctx.send(embed=await case.get_case_msg_content())
99 
100     @commands.command(usage="[case] <reason>")
101     @commands.guild_only()
102     async def reason(self, ctx: commands.Context, *, reason: str):
103         """Lets you specify a reason for mod-log's cases
104         
105         Please note that you can only edit cases you are
106         the owner of unless you are a mod/admin or the server owner.
107         
108         If no number is specified, the latest case will be used."""
109         author = ctx.author
110         guild = ctx.guild
111         potential_case = reason.split()[0]
112         if potential_case.isdigit():
113             case = int(potential_case)
114             reason = reason.replace(potential_case, "")
115         else:
116             case = str(int(await modlog.get_next_case_number(guild)) - 1)
117             # latest case
118         try:
119             case_before = await modlog.get_case(case, guild, self.bot)
120         except RuntimeError:
121             await ctx.send(_("That case does not exist!"))
122             return
123         else:
124             if case_before.moderator is None:
125                 # No mod set, so attempt to find out if the author
126                 # triggered the case creation with an action
127                 bot_perms = guild.me.guild_permissions
128                 if bot_perms.view_audit_log:
129                     case_type = await modlog.get_casetype(case_before.action_type, guild)
130                     if case_type is not None and case_type.audit_type is not None:
131                         audit_type = getattr(discord.AuditLogAction, case_type.audit_type)
132                         if audit_type:
133                             audit_case = None
134                             async for entry in guild.audit_logs(action=audit_type):
135                                 if (
136                                     entry.target.id == case_before.user.id
137                                     and entry.action == audit_type
138                                 ):
139                                     audit_case = entry
140                                     break
141                             if audit_case:
142                                 case_before.moderator = audit_case.user
143             is_guild_owner = author == guild.owner
144             is_case_author = author == case_before.moderator
145             author_is_mod = await ctx.bot.is_mod(author)
146             if not (is_guild_owner or is_case_author or author_is_mod):
147                 await ctx.send(_("You are not authorized to modify that case!"))
148                 return
149             to_modify = {"reason": reason}
150             if case_before.moderator != author:
151                 to_modify["amended_by"] = author
152             to_modify["modified_at"] = ctx.message.created_at.timestamp()
153             await case_before.edit(to_modify)
154             await ctx.send(_("Reason has been updated."))
155
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/redbot/cogs/modlog/modlog.py b/redbot/cogs/modlog/modlog.py
--- a/redbot/cogs/modlog/modlog.py
+++ b/redbot/cogs/modlog/modlog.py
@@ -95,7 +95,10 @@
             await ctx.send(_("That case does not exist for that server"))
             return
         else:
-            await ctx.send(embed=await case.get_case_msg_content())
+            if await ctx.embed_requested():
+                await ctx.send(embed=await case.message_content(embed=True))
+            else:
+                await ctx.send(await case.message_content(embed=False))
 
     @commands.command(usage="[case] <reason>")
     @commands.guild_only()

{"golden_diff": "diff --git a/redbot/cogs/modlog/modlog.py b/redbot/cogs/modlog/modlog.py\n--- a/redbot/cogs/modlog/modlog.py\n+++ b/redbot/cogs/modlog/modlog.py\n@@ -95,7 +95,10 @@\n             await ctx.send(_(\"That case does not exist for that server\"))\n             return\n         else:\n-            await ctx.send(embed=await case.get_case_msg_content())\n+            if await ctx.embed_requested():\n+                await ctx.send(embed=await case.message_content(embed=True))\n+            else:\n+                await ctx.send(await case.message_content(embed=False))\n \n     @commands.command(usage=\"[case] <reason>\")\n     @commands.guild_only()\n", "issue": "[V3 ModLog] Error in command \"case\"\n# Command bugs\r\n\r\n\r\n#### Command name\r\n\r\n[p]case\r\n\r\n#### What cog is this command from?\r\n\r\nModLog\r\n\r\n#### What were you expecting to happen?\r\n\r\nTo show me information about a case.\r\n\r\n\r\n#### What actually happened?\r\nI get this error:\r\n![image](https://user-images.githubusercontent.com/30272172/43678766-a4a40388-97d6-11e8-90c7-d48ae2c54239.png)\r\n\r\n\r\n\r\n#### How can we reproduce this issue?\r\n\r\n1. Have a modlog with cases.\r\n2. Do [p]case\r\n\n", "before_files": [{"content": "import discord\n\nfrom redbot.core import checks, modlog, commands\nfrom redbot.core.bot import Red\nfrom redbot.core.i18n import Translator, cog_i18n\nfrom redbot.core.utils.chat_formatting import box\n\n_ = Translator(\"ModLog\", __file__)\n\n\n@cog_i18n(_)\nclass ModLog:\n    \"\"\"Log for mod actions\"\"\"\n\n    def __init__(self, bot: Red):\n        self.bot = bot\n\n    @commands.group()\n    @checks.guildowner_or_permissions(administrator=True)\n    async def modlogset(self, ctx: commands.Context):\n        \"\"\"Settings for the mod log\"\"\"\n        pass\n\n    @modlogset.command()\n    @commands.guild_only()\n    async def modlog(self, ctx: commands.Context, channel: discord.TextChannel = None):\n        \"\"\"Sets a channel as mod log\n\n        Leaving the channel parameter empty will deactivate it\"\"\"\n        guild = ctx.guild\n        if channel:\n            if channel.permissions_for(guild.me).send_messages:\n                await modlog.set_modlog_channel(guild, channel)\n                await ctx.send(_(\"Mod events will be sent to {}\").format(channel.mention))\n            else:\n                await ctx.send(\n                    _(\"I do not have permissions to send messages in {}!\").format(channel.mention)\n                )\n        else:\n            try:\n                await modlog.get_modlog_channel(guild)\n            except RuntimeError:\n                await ctx.send_help()\n            else:\n                await modlog.set_modlog_channel(guild, None)\n                await ctx.send(_(\"Mod log deactivated.\"))\n\n    @modlogset.command(name=\"cases\")\n    @commands.guild_only()\n    async def set_cases(self, ctx: commands.Context, action: str = None):\n        \"\"\"Enables or disables case creation for each type of mod action\"\"\"\n        guild = ctx.guild\n\n        if action is None:  # No args given\n            casetypes = await modlog.get_all_casetypes(guild)\n            await ctx.send_help()\n            title = _(\"Current settings:\")\n            msg = \"\"\n            for ct in casetypes:\n                enabled = await ct.is_enabled()\n                value = \"enabled\" if enabled else \"disabled\"\n                msg += \"%s : %s\\n\" % (ct.name, value)\n\n            msg = title + \"\\n\" + box(msg)\n            await ctx.send(msg)\n            return\n        casetype = await modlog.get_casetype(action, guild)\n        if not casetype:\n            await ctx.send(_(\"That action is not registered\"))\n        else:\n\n            enabled = await casetype.is_enabled()\n            await casetype.set_enabled(True if not enabled else False)\n\n            msg = _(\"Case creation for {} actions is now {}.\").format(\n                action, \"enabled\" if not enabled else \"disabled\"\n            )\n            await ctx.send(msg)\n\n    @modlogset.command()\n    @commands.guild_only()\n    async def resetcases(self, ctx: commands.Context):\n        \"\"\"Resets modlog's cases\"\"\"\n        guild = ctx.guild\n        await modlog.reset_cases(guild)\n        await ctx.send(_(\"Cases have been reset.\"))\n\n    @commands.command()\n    @commands.guild_only()\n    async def case(self, ctx: commands.Context, number: int):\n        \"\"\"Shows the specified case\"\"\"\n        try:\n            case = await modlog.get_case(number, ctx.guild, self.bot)\n        except RuntimeError:\n            await ctx.send(_(\"That case does not exist for that server\"))\n            return\n        else:\n            await ctx.send(embed=await case.get_case_msg_content())\n\n    @commands.command(usage=\"[case] <reason>\")\n    @commands.guild_only()\n    async def reason(self, ctx: commands.Context, *, reason: str):\n        \"\"\"Lets you specify a reason for mod-log's cases\n        \n        Please note that you can only edit cases you are\n        the owner of unless you are a mod/admin or the server owner.\n        \n        If no number is specified, the latest case will be used.\"\"\"\n        author = ctx.author\n        guild = ctx.guild\n        potential_case = reason.split()[0]\n        if potential_case.isdigit():\n            case = int(potential_case)\n            reason = reason.replace(potential_case, \"\")\n        else:\n            case = str(int(await modlog.get_next_case_number(guild)) - 1)\n            # latest case\n        try:\n            case_before = await modlog.get_case(case, guild, self.bot)\n        except RuntimeError:\n            await ctx.send(_(\"That case does not exist!\"))\n            return\n        else:\n            if case_before.moderator is None:\n                # No mod set, so attempt to find out if the author\n                # triggered the case creation with an action\n                bot_perms = guild.me.guild_permissions\n                if bot_perms.view_audit_log:\n                    case_type = await modlog.get_casetype(case_before.action_type, guild)\n                    if case_type is not None and case_type.audit_type is not None:\n                        audit_type = getattr(discord.AuditLogAction, case_type.audit_type)\n                        if audit_type:\n                            audit_case = None\n                            async for entry in guild.audit_logs(action=audit_type):\n                                if (\n                                    entry.target.id == case_before.user.id\n                                    and entry.action == audit_type\n                                ):\n                                    audit_case = entry\n                                    break\n                            if audit_case:\n                                case_before.moderator = audit_case.user\n            is_guild_owner = author == guild.owner\n            is_case_author = author == case_before.moderator\n            author_is_mod = await ctx.bot.is_mod(author)\n            if not (is_guild_owner or is_case_author or author_is_mod):\n                await ctx.send(_(\"You are not authorized to modify that case!\"))\n                return\n            to_modify = {\"reason\": reason}\n            if case_before.moderator != author:\n                to_modify[\"amended_by\"] = author\n            to_modify[\"modified_at\"] = ctx.message.created_at.timestamp()\n            await case_before.edit(to_modify)\n            await ctx.send(_(\"Reason has been updated.\"))\n", "path": "redbot/cogs/modlog/modlog.py"}], "after_files": [{"content": "import discord\n\nfrom redbot.core import checks, modlog, commands\nfrom redbot.core.bot import Red\nfrom redbot.core.i18n import Translator, cog_i18n\nfrom redbot.core.utils.chat_formatting import box\n\n_ = Translator(\"ModLog\", __file__)\n\n\n@cog_i18n(_)\nclass ModLog:\n    \"\"\"Log for mod actions\"\"\"\n\n    def __init__(self, bot: Red):\n        self.bot = bot\n\n    @commands.group()\n    @checks.guildowner_or_permissions(administrator=True)\n    async def modlogset(self, ctx: commands.Context):\n        \"\"\"Settings for the mod log\"\"\"\n        pass\n\n    @modlogset.command()\n    @commands.guild_only()\n    async def modlog(self, ctx: commands.Context, channel: discord.TextChannel = None):\n        \"\"\"Sets a channel as mod log\n\n        Leaving the channel parameter empty will deactivate it\"\"\"\n        guild = ctx.guild\n        if channel:\n            if channel.permissions_for(guild.me).send_messages:\n                await modlog.set_modlog_channel(guild, channel)\n                await ctx.send(_(\"Mod events will be sent to {}\").format(channel.mention))\n            else:\n                await ctx.send(\n                    _(\"I do not have permissions to send messages in {}!\").format(channel.mention)\n                )\n        else:\n            try:\n                await modlog.get_modlog_channel(guild)\n            except RuntimeError:\n                await ctx.send_help()\n            else:\n                await modlog.set_modlog_channel(guild, None)\n                await ctx.send(_(\"Mod log deactivated.\"))\n\n    @modlogset.command(name=\"cases\")\n    @commands.guild_only()\n    async def set_cases(self, ctx: commands.Context, action: str = None):\n        \"\"\"Enables or disables case creation for each type of mod action\"\"\"\n        guild = ctx.guild\n\n        if action is None:  # No args given\n            casetypes = await modlog.get_all_casetypes(guild)\n            await ctx.send_help()\n            title = _(\"Current settings:\")\n            msg = \"\"\n            for ct in casetypes:\n                enabled = await ct.is_enabled()\n                value = \"enabled\" if enabled else \"disabled\"\n                msg += \"%s : %s\\n\" % (ct.name, value)\n\n            msg = title + \"\\n\" + box(msg)\n            await ctx.send(msg)\n            return\n        casetype = await modlog.get_casetype(action, guild)\n        if not casetype:\n            await ctx.send(_(\"That action is not registered\"))\n        else:\n\n            enabled = await casetype.is_enabled()\n            await casetype.set_enabled(True if not enabled else False)\n\n            msg = _(\"Case creation for {} actions is now {}.\").format(\n                action, \"enabled\" if not enabled else \"disabled\"\n            )\n            await ctx.send(msg)\n\n    @modlogset.command()\n    @commands.guild_only()\n    async def resetcases(self, ctx: commands.Context):\n        \"\"\"Resets modlog's cases\"\"\"\n        guild = ctx.guild\n        await modlog.reset_cases(guild)\n        await ctx.send(_(\"Cases have been reset.\"))\n\n    @commands.command()\n    @commands.guild_only()\n    async def case(self, ctx: commands.Context, number: int):\n        \"\"\"Shows the specified case\"\"\"\n        try:\n            case = await modlog.get_case(number, ctx.guild, self.bot)\n        except RuntimeError:\n            await ctx.send(_(\"That case does not exist for that server\"))\n            return\n        else:\n            if await ctx.embed_requested():\n                await ctx.send(embed=await case.message_content(embed=True))\n            else:\n                await ctx.send(await case.message_content(embed=False))\n\n    @commands.command(usage=\"[case] <reason>\")\n    @commands.guild_only()\n    async def reason(self, ctx: commands.Context, *, reason: str):\n        \"\"\"Lets you specify a reason for mod-log's cases\n        \n        Please note that you can only edit cases you are\n        the owner of unless you are a mod/admin or the server owner.\n        \n        If no number is specified, the latest case will be used.\"\"\"\n        author = ctx.author\n        guild = ctx.guild\n        potential_case = reason.split()[0]\n        if potential_case.isdigit():\n            case = int(potential_case)\n            reason = reason.replace(potential_case, \"\")\n        else:\n            case = str(int(await modlog.get_next_case_number(guild)) - 1)\n            # latest case\n        try:\n            case_before = await modlog.get_case(case, guild, self.bot)\n        except RuntimeError:\n            await ctx.send(_(\"That case does not exist!\"))\n            return\n        else:\n            if case_before.moderator is None:\n                # No mod set, so attempt to find out if the author\n                # triggered the case creation with an action\n                bot_perms = guild.me.guild_permissions\n                if bot_perms.view_audit_log:\n                    case_type = await modlog.get_casetype(case_before.action_type, guild)\n                    if case_type is not None and case_type.audit_type is not None:\n                        audit_type = getattr(discord.AuditLogAction, case_type.audit_type)\n                        if audit_type:\n                            audit_case = None\n                            async for entry in guild.audit_logs(action=audit_type):\n                                if (\n                                    entry.target.id == case_before.user.id\n                                    and entry.action == audit_type\n                                ):\n                                    audit_case = entry\n                                    break\n                            if audit_case:\n                                case_before.moderator = audit_case.user\n            is_guild_owner = author == guild.owner\n            is_case_author = author == case_before.moderator\n            author_is_mod = await ctx.bot.is_mod(author)\n            if not (is_guild_owner or is_case_author or author_is_mod):\n                await ctx.send(_(\"You are not authorized to modify that case!\"))\n                return\n            to_modify = {\"reason\": reason}\n            if case_before.moderator != author:\n                to_modify[\"amended_by\"] = author\n            to_modify[\"modified_at\"] = ctx.message.created_at.timestamp()\n            await case_before.edit(to_modify)\n            await ctx.send(_(\"Reason has been updated.\"))\n", "path": "redbot/cogs/modlog/modlog.py"}]}