We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
AttributeError: 'MissingRequiredArgument' object has no attribute 'original'
https://sentry.io/will-tekulve/bot-development/issues/418646879/

```
AttributeError: 'MissingRequiredArgument' object has no attribute 'original'
  File "redbot/core/events.py", line 187, in on_command_error
    exc_info=error.original)

Exception in on_on_command_error
```

--- 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/core/events.py`
Content:
```
1 import sys
2 import codecs
3 import datetime
4 import logging
5 import pkg_resources
6 import traceback
7 from pkg_resources import DistributionNotFound
8 
9 
10 import discord
11 from discord.ext import commands
12 
13 from . import __version__
14 from .data_manager import storage_type
15 from .utils.chat_formatting import inline, bordered
16 from .rpc import initialize
17 from colorama import Fore, Style, init
18 
19 log = logging.getLogger("red")
20 sentry_log = logging.getLogger("red.sentry")
21 init()
22 
23 INTRO = """
24 ______         _           ______ _                       _  ______       _   
25 | ___ \       | |          |  _  (_)                     | | | ___ \     | |  
26 | |_/ /___  __| |  ______  | | | |_ ___  ___ ___  _ __ __| | | |_/ / ___ | |_ 
27 |    // _ \/ _` | |______| | | | | / __|/ __/ _ \| '__/ _` | | ___ \/ _ \| __|
28 | |\ \  __/ (_| |          | |/ /| \__ \ (_| (_) | | | (_| | | |_/ / (_) | |_ 
29 \_| \_\___|\__,_|          |___/ |_|___/\___\___/|_|  \__,_| \____/ \___/ \__|
30 """
31 
32 
33 def init_events(bot, cli_flags):
34 
35     @bot.event
36     async def on_connect():
37         if bot.uptime is None:
38             print("Connected to Discord. Getting ready...")
39 
40     @bot.event
41     async def on_ready():
42         if bot.uptime is not None:
43             return
44 
45         bot.uptime = datetime.datetime.utcnow()
46 
47         if cli_flags.no_cogs is False:
48             print("Loading packages...")
49             failed = []
50             packages = await bot.db.packages()
51 
52             for package in packages:
53                 try:
54                     spec = await bot.cog_mgr.find_cog(package)
55                     bot.load_extension(spec)
56                 except Exception as e:
57                     log.exception("Failed to load package {}".format(package),
58                                   exc_info=e)
59                     await bot.remove_loaded_package(package)
60             if packages:
61                 print("Loaded packages: " + ", ".join(packages))
62 
63         guilds = len(bot.guilds)
64         users = len(set([m for m in bot.get_all_members()]))
65 
66         try:
67             data = await bot.application_info()
68             invite_url = discord.utils.oauth_url(data.id)
69         except:
70             if bot.user.bot:
71                 invite_url = "Could not fetch invite url"
72             else:
73                 invite_url = None
74 
75         prefixes = await bot.db.prefix()
76         lang = await bot.db.locale()
77         red_version = __version__
78         red_pkg = pkg_resources.get_distribution("Red-DiscordBot")
79         dpy_version = discord.__version__
80 
81         INFO = [str(bot.user), "Prefixes: {}".format(', '.join(prefixes)),
82                 'Language: {}'.format(lang),
83                 "Red Bot Version: {}".format(red_version),
84                 "Discord.py Version: {}".format(dpy_version),
85                 "Shards: {}".format(bot.shard_count)]
86 
87         if guilds:
88             INFO.extend(("Servers: {}".format(guilds), "Users: {}".format(users)))
89         else:
90             print("Ready. I'm not in any server yet!")
91 
92         INFO.append('{} cogs with {} commands'.format(len(bot.cogs), len(bot.commands)))
93 
94         INFO2 = []
95 
96         sentry = await bot.db.enable_sentry()
97         mongo_enabled = storage_type() != "JSON"
98         reqs_installed = {
99             "voice": None,
100             "docs": None,
101             "test": None
102         }
103         for key in reqs_installed.keys():
104             reqs = [x.name for x in red_pkg._dep_map[key]]
105             try:
106                 pkg_resources.require(reqs)
107             except DistributionNotFound:
108                 reqs_installed[key] = False
109             else:
110                 reqs_installed[key] = True
111 
112         options = (
113             ("Error Reporting", sentry),
114             ("MongoDB", mongo_enabled),
115             ("Voice", reqs_installed["voice"]),
116             ("Docs", reqs_installed["docs"]),
117             ("Tests", reqs_installed["test"])
118         )
119 
120         on_symbol, off_symbol = _get_settings_symbols()
121 
122         for option, enabled in options:
123             enabled = on_symbol if enabled else off_symbol
124             INFO2.append("{} {}".format(enabled, option))
125 
126         print(Fore.RED + INTRO)
127         print(Style.RESET_ALL)
128         print(bordered(INFO, INFO2))
129 
130         if invite_url:
131             print("\nInvite URL: {}\n".format(invite_url))
132 
133         if bot.rpc_enabled:
134             await initialize(bot)
135 
136     @bot.event
137     async def on_error(event_method, *args, **kwargs):
138         sentry_log.exception("Exception in on_{}".format(event_method))
139 
140     @bot.event
141     async def on_command_error(ctx, error):
142         if isinstance(error, commands.MissingRequiredArgument):
143             await ctx.send_help()
144         elif isinstance(error, commands.BadArgument):
145             await ctx.send_help()
146         elif isinstance(error, commands.DisabledCommand):
147             await ctx.send("That command is disabled.")
148         elif isinstance(error, commands.CommandInvokeError):
149             # Need to test if the following still works
150             """
151             no_dms = "Cannot send messages to this user"
152             is_help_cmd = ctx.command.qualified_name == "help"
153             is_forbidden = isinstance(error.original, discord.Forbidden)
154             if is_help_cmd and is_forbidden and error.original.text == no_dms:
155                 msg = ("I couldn't send the help message to you in DM. Either"
156                        " you blocked me or you disabled DMs in this server.")
157                 await ctx.send(msg)
158                 return
159             """
160             log.exception("Exception in command '{}'"
161                           "".format(ctx.command.qualified_name),
162                           exc_info=error.original)
163             message = ("Error in command '{}'. Check your console or "
164                        "logs for details."
165                        "".format(ctx.command.qualified_name))
166             exception_log = ("Exception in command '{}'\n"
167                              "".format(ctx.command.qualified_name))
168             exception_log += "".join(traceback.format_exception(type(error),
169                                      error, error.__traceback__))
170             bot._last_exception = exception_log
171             await ctx.send(inline(message))
172         elif isinstance(error, commands.CommandNotFound):
173             pass
174         elif isinstance(error, commands.CheckFailure):
175             await ctx.send("⛔ You are not authorized to issue that command.")
176         elif isinstance(error, commands.NoPrivateMessage):
177             await ctx.send("That command is not available in DMs.")
178         elif isinstance(error, commands.CommandOnCooldown):
179             await ctx.send("This command is on cooldown. "
180                            "Try again in {:.2f}s"
181                            "".format(error.retry_after))
182         else:
183             log.exception(type(error).__name__, exc_info=error)
184 
185         sentry_log.exception("Exception in command '{}'"
186                              "".format(ctx.command.qualified_name),
187                              exc_info=error.original)
188 
189     @bot.event
190     async def on_message(message):
191         bot.counter["messages_read"] += 1
192         await bot.process_commands(message)
193 
194     @bot.event
195     async def on_resumed():
196         bot.counter["sessions_resumed"] += 1
197 
198     @bot.event
199     async def on_command(command):
200         bot.counter["processed_commands"] += 1
201 
202 def _get_settings_symbols():
203     """Get symbols for displaying settings on stdout.
204 
205     This is so we don't get encoding errors when trying to print unicode
206     emojis to stdout (particularly with Windows Command Prompt).
207     """
208     encoder = codecs.getencoder(sys.stdout.encoding)
209     check_mark = "\N{SQUARE ROOT}"
210     try:
211         encoder(check_mark)
212     except UnicodeEncodeError:
213         on_symbol = "[X]"
214         off_symbol = "[ ]"
215     else:
216         on_symbol = check_mark
217         off_symbol = "X"
218 
219     return on_symbol, off_symbol
220
```
--- 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/core/events.py b/redbot/core/events.py
--- a/redbot/core/events.py
+++ b/redbot/core/events.py
@@ -135,7 +135,7 @@
 
     @bot.event
     async def on_error(event_method, *args, **kwargs):
-        sentry_log.exception("Exception in on_{}".format(event_method))
+        sentry_log.exception("Exception in {}".format(event_method))
 
     @bot.event
     async def on_command_error(ctx, error):
@@ -160,6 +160,10 @@
             log.exception("Exception in command '{}'"
                           "".format(ctx.command.qualified_name),
                           exc_info=error.original)
+            sentry_log.exception("Exception in command '{}'"
+                                 "".format(ctx.command.qualified_name),
+                                 exc_info=error.original)
+
             message = ("Error in command '{}'. Check your console or "
                        "logs for details."
                        "".format(ctx.command.qualified_name))
@@ -181,10 +185,13 @@
                            "".format(error.retry_after))
         else:
             log.exception(type(error).__name__, exc_info=error)
+            try:
+                sentry_error = error.original
+            except AttributeError:
+                sentry_error = error
 
-        sentry_log.exception("Exception in command '{}'"
-                             "".format(ctx.command.qualified_name),
-                             exc_info=error.original)
+            sentry_log.exception("Unhandled command error.",
+                                 exc_info=sentry_error)
 
     @bot.event
     async def on_message(message):

{"golden_diff": "diff --git a/redbot/core/events.py b/redbot/core/events.py\n--- a/redbot/core/events.py\n+++ b/redbot/core/events.py\n@@ -135,7 +135,7 @@\n \n     @bot.event\n     async def on_error(event_method, *args, **kwargs):\n-        sentry_log.exception(\"Exception in on_{}\".format(event_method))\n+        sentry_log.exception(\"Exception in {}\".format(event_method))\n \n     @bot.event\n     async def on_command_error(ctx, error):\n@@ -160,6 +160,10 @@\n             log.exception(\"Exception in command '{}'\"\n                           \"\".format(ctx.command.qualified_name),\n                           exc_info=error.original)\n+            sentry_log.exception(\"Exception in command '{}'\"\n+                                 \"\".format(ctx.command.qualified_name),\n+                                 exc_info=error.original)\n+\n             message = (\"Error in command '{}'. Check your console or \"\n                        \"logs for details.\"\n                        \"\".format(ctx.command.qualified_name))\n@@ -181,10 +185,13 @@\n                            \"\".format(error.retry_after))\n         else:\n             log.exception(type(error).__name__, exc_info=error)\n+            try:\n+                sentry_error = error.original\n+            except AttributeError:\n+                sentry_error = error\n \n-        sentry_log.exception(\"Exception in command '{}'\"\n-                             \"\".format(ctx.command.qualified_name),\n-                             exc_info=error.original)\n+            sentry_log.exception(\"Unhandled command error.\",\n+                                 exc_info=sentry_error)\n \n     @bot.event\n     async def on_message(message):\n", "issue": "AttributeError: 'MissingRequiredArgument' object has no attribute 'original'\nhttps://sentry.io/will-tekulve/bot-development/issues/418646879/\n\n```\nAttributeError: 'MissingRequiredArgument' object has no attribute 'original'\n  File \"redbot/core/events.py\", line 187, in on_command_error\n    exc_info=error.original)\n\nException in on_on_command_error\n```\n", "before_files": [{"content": "import sys\nimport codecs\nimport datetime\nimport logging\nimport pkg_resources\nimport traceback\nfrom pkg_resources import DistributionNotFound\n\n\nimport discord\nfrom discord.ext import commands\n\nfrom . import __version__\nfrom .data_manager import storage_type\nfrom .utils.chat_formatting import inline, bordered\nfrom .rpc import initialize\nfrom colorama import Fore, Style, init\n\nlog = logging.getLogger(\"red\")\nsentry_log = logging.getLogger(\"red.sentry\")\ninit()\n\nINTRO = \"\"\"\n______         _           ______ _                       _  ______       _   \n| ___ \\       | |          |  _  (_)                     | | | ___ \\     | |  \n| |_/ /___  __| |  ______  | | | |_ ___  ___ ___  _ __ __| | | |_/ / ___ | |_ \n|    // _ \\/ _` | |______| | | | | / __|/ __/ _ \\| '__/ _` | | ___ \\/ _ \\| __|\n| |\\ \\  __/ (_| |          | |/ /| \\__ \\ (_| (_) | | | (_| | | |_/ / (_) | |_ \n\\_| \\_\\___|\\__,_|          |___/ |_|___/\\___\\___/|_|  \\__,_| \\____/ \\___/ \\__|\n\"\"\"\n\n\ndef init_events(bot, cli_flags):\n\n    @bot.event\n    async def on_connect():\n        if bot.uptime is None:\n            print(\"Connected to Discord. Getting ready...\")\n\n    @bot.event\n    async def on_ready():\n        if bot.uptime is not None:\n            return\n\n        bot.uptime = datetime.datetime.utcnow()\n\n        if cli_flags.no_cogs is False:\n            print(\"Loading packages...\")\n            failed = []\n            packages = await bot.db.packages()\n\n            for package in packages:\n                try:\n                    spec = await bot.cog_mgr.find_cog(package)\n                    bot.load_extension(spec)\n                except Exception as e:\n                    log.exception(\"Failed to load package {}\".format(package),\n                                  exc_info=e)\n                    await bot.remove_loaded_package(package)\n            if packages:\n                print(\"Loaded packages: \" + \", \".join(packages))\n\n        guilds = len(bot.guilds)\n        users = len(set([m for m in bot.get_all_members()]))\n\n        try:\n            data = await bot.application_info()\n            invite_url = discord.utils.oauth_url(data.id)\n        except:\n            if bot.user.bot:\n                invite_url = \"Could not fetch invite url\"\n            else:\n                invite_url = None\n\n        prefixes = await bot.db.prefix()\n        lang = await bot.db.locale()\n        red_version = __version__\n        red_pkg = pkg_resources.get_distribution(\"Red-DiscordBot\")\n        dpy_version = discord.__version__\n\n        INFO = [str(bot.user), \"Prefixes: {}\".format(', '.join(prefixes)),\n                'Language: {}'.format(lang),\n                \"Red Bot Version: {}\".format(red_version),\n                \"Discord.py Version: {}\".format(dpy_version),\n                \"Shards: {}\".format(bot.shard_count)]\n\n        if guilds:\n            INFO.extend((\"Servers: {}\".format(guilds), \"Users: {}\".format(users)))\n        else:\n            print(\"Ready. I'm not in any server yet!\")\n\n        INFO.append('{} cogs with {} commands'.format(len(bot.cogs), len(bot.commands)))\n\n        INFO2 = []\n\n        sentry = await bot.db.enable_sentry()\n        mongo_enabled = storage_type() != \"JSON\"\n        reqs_installed = {\n            \"voice\": None,\n            \"docs\": None,\n            \"test\": None\n        }\n        for key in reqs_installed.keys():\n            reqs = [x.name for x in red_pkg._dep_map[key]]\n            try:\n                pkg_resources.require(reqs)\n            except DistributionNotFound:\n                reqs_installed[key] = False\n            else:\n                reqs_installed[key] = True\n\n        options = (\n            (\"Error Reporting\", sentry),\n            (\"MongoDB\", mongo_enabled),\n            (\"Voice\", reqs_installed[\"voice\"]),\n            (\"Docs\", reqs_installed[\"docs\"]),\n            (\"Tests\", reqs_installed[\"test\"])\n        )\n\n        on_symbol, off_symbol = _get_settings_symbols()\n\n        for option, enabled in options:\n            enabled = on_symbol if enabled else off_symbol\n            INFO2.append(\"{} {}\".format(enabled, option))\n\n        print(Fore.RED + INTRO)\n        print(Style.RESET_ALL)\n        print(bordered(INFO, INFO2))\n\n        if invite_url:\n            print(\"\\nInvite URL: {}\\n\".format(invite_url))\n\n        if bot.rpc_enabled:\n            await initialize(bot)\n\n    @bot.event\n    async def on_error(event_method, *args, **kwargs):\n        sentry_log.exception(\"Exception in on_{}\".format(event_method))\n\n    @bot.event\n    async def on_command_error(ctx, error):\n        if isinstance(error, commands.MissingRequiredArgument):\n            await ctx.send_help()\n        elif isinstance(error, commands.BadArgument):\n            await ctx.send_help()\n        elif isinstance(error, commands.DisabledCommand):\n            await ctx.send(\"That command is disabled.\")\n        elif isinstance(error, commands.CommandInvokeError):\n            # Need to test if the following still works\n            \"\"\"\n            no_dms = \"Cannot send messages to this user\"\n            is_help_cmd = ctx.command.qualified_name == \"help\"\n            is_forbidden = isinstance(error.original, discord.Forbidden)\n            if is_help_cmd and is_forbidden and error.original.text == no_dms:\n                msg = (\"I couldn't send the help message to you in DM. Either\"\n                       \" you blocked me or you disabled DMs in this server.\")\n                await ctx.send(msg)\n                return\n            \"\"\"\n            log.exception(\"Exception in command '{}'\"\n                          \"\".format(ctx.command.qualified_name),\n                          exc_info=error.original)\n            message = (\"Error in command '{}'. Check your console or \"\n                       \"logs for details.\"\n                       \"\".format(ctx.command.qualified_name))\n            exception_log = (\"Exception in command '{}'\\n\"\n                             \"\".format(ctx.command.qualified_name))\n            exception_log += \"\".join(traceback.format_exception(type(error),\n                                     error, error.__traceback__))\n            bot._last_exception = exception_log\n            await ctx.send(inline(message))\n        elif isinstance(error, commands.CommandNotFound):\n            pass\n        elif isinstance(error, commands.CheckFailure):\n            await ctx.send(\"\u26d4 You are not authorized to issue that command.\")\n        elif isinstance(error, commands.NoPrivateMessage):\n            await ctx.send(\"That command is not available in DMs.\")\n        elif isinstance(error, commands.CommandOnCooldown):\n            await ctx.send(\"This command is on cooldown. \"\n                           \"Try again in {:.2f}s\"\n                           \"\".format(error.retry_after))\n        else:\n            log.exception(type(error).__name__, exc_info=error)\n\n        sentry_log.exception(\"Exception in command '{}'\"\n                             \"\".format(ctx.command.qualified_name),\n                             exc_info=error.original)\n\n    @bot.event\n    async def on_message(message):\n        bot.counter[\"messages_read\"] += 1\n        await bot.process_commands(message)\n\n    @bot.event\n    async def on_resumed():\n        bot.counter[\"sessions_resumed\"] += 1\n\n    @bot.event\n    async def on_command(command):\n        bot.counter[\"processed_commands\"] += 1\n\ndef _get_settings_symbols():\n    \"\"\"Get symbols for displaying settings on stdout.\n\n    This is so we don't get encoding errors when trying to print unicode\n    emojis to stdout (particularly with Windows Command Prompt).\n    \"\"\"\n    encoder = codecs.getencoder(sys.stdout.encoding)\n    check_mark = \"\\N{SQUARE ROOT}\"\n    try:\n        encoder(check_mark)\n    except UnicodeEncodeError:\n        on_symbol = \"[X]\"\n        off_symbol = \"[ ]\"\n    else:\n        on_symbol = check_mark\n        off_symbol = \"X\"\n\n    return on_symbol, off_symbol\n", "path": "redbot/core/events.py"}], "after_files": [{"content": "import sys\nimport codecs\nimport datetime\nimport logging\nimport pkg_resources\nimport traceback\nfrom pkg_resources import DistributionNotFound\n\n\nimport discord\nfrom discord.ext import commands\n\nfrom . import __version__\nfrom .data_manager import storage_type\nfrom .utils.chat_formatting import inline, bordered\nfrom .rpc import initialize\nfrom colorama import Fore, Style, init\n\nlog = logging.getLogger(\"red\")\nsentry_log = logging.getLogger(\"red.sentry\")\ninit()\n\nINTRO = \"\"\"\n______         _           ______ _                       _  ______       _   \n| ___ \\       | |          |  _  (_)                     | | | ___ \\     | |  \n| |_/ /___  __| |  ______  | | | |_ ___  ___ ___  _ __ __| | | |_/ / ___ | |_ \n|    // _ \\/ _` | |______| | | | | / __|/ __/ _ \\| '__/ _` | | ___ \\/ _ \\| __|\n| |\\ \\  __/ (_| |          | |/ /| \\__ \\ (_| (_) | | | (_| | | |_/ / (_) | |_ \n\\_| \\_\\___|\\__,_|          |___/ |_|___/\\___\\___/|_|  \\__,_| \\____/ \\___/ \\__|\n\"\"\"\n\n\ndef init_events(bot, cli_flags):\n\n    @bot.event\n    async def on_connect():\n        if bot.uptime is None:\n            print(\"Connected to Discord. Getting ready...\")\n\n    @bot.event\n    async def on_ready():\n        if bot.uptime is not None:\n            return\n\n        bot.uptime = datetime.datetime.utcnow()\n\n        if cli_flags.no_cogs is False:\n            print(\"Loading packages...\")\n            failed = []\n            packages = await bot.db.packages()\n\n            for package in packages:\n                try:\n                    spec = await bot.cog_mgr.find_cog(package)\n                    bot.load_extension(spec)\n                except Exception as e:\n                    log.exception(\"Failed to load package {}\".format(package),\n                                  exc_info=e)\n                    await bot.remove_loaded_package(package)\n            if packages:\n                print(\"Loaded packages: \" + \", \".join(packages))\n\n        guilds = len(bot.guilds)\n        users = len(set([m for m in bot.get_all_members()]))\n\n        try:\n            data = await bot.application_info()\n            invite_url = discord.utils.oauth_url(data.id)\n        except:\n            if bot.user.bot:\n                invite_url = \"Could not fetch invite url\"\n            else:\n                invite_url = None\n\n        prefixes = await bot.db.prefix()\n        lang = await bot.db.locale()\n        red_version = __version__\n        red_pkg = pkg_resources.get_distribution(\"Red-DiscordBot\")\n        dpy_version = discord.__version__\n\n        INFO = [str(bot.user), \"Prefixes: {}\".format(', '.join(prefixes)),\n                'Language: {}'.format(lang),\n                \"Red Bot Version: {}\".format(red_version),\n                \"Discord.py Version: {}\".format(dpy_version),\n                \"Shards: {}\".format(bot.shard_count)]\n\n        if guilds:\n            INFO.extend((\"Servers: {}\".format(guilds), \"Users: {}\".format(users)))\n        else:\n            print(\"Ready. I'm not in any server yet!\")\n\n        INFO.append('{} cogs with {} commands'.format(len(bot.cogs), len(bot.commands)))\n\n        INFO2 = []\n\n        sentry = await bot.db.enable_sentry()\n        mongo_enabled = storage_type() != \"JSON\"\n        reqs_installed = {\n            \"voice\": None,\n            \"docs\": None,\n            \"test\": None\n        }\n        for key in reqs_installed.keys():\n            reqs = [x.name for x in red_pkg._dep_map[key]]\n            try:\n                pkg_resources.require(reqs)\n            except DistributionNotFound:\n                reqs_installed[key] = False\n            else:\n                reqs_installed[key] = True\n\n        options = (\n            (\"Error Reporting\", sentry),\n            (\"MongoDB\", mongo_enabled),\n            (\"Voice\", reqs_installed[\"voice\"]),\n            (\"Docs\", reqs_installed[\"docs\"]),\n            (\"Tests\", reqs_installed[\"test\"])\n        )\n\n        on_symbol, off_symbol = _get_settings_symbols()\n\n        for option, enabled in options:\n            enabled = on_symbol if enabled else off_symbol\n            INFO2.append(\"{} {}\".format(enabled, option))\n\n        print(Fore.RED + INTRO)\n        print(Style.RESET_ALL)\n        print(bordered(INFO, INFO2))\n\n        if invite_url:\n            print(\"\\nInvite URL: {}\\n\".format(invite_url))\n\n        if bot.rpc_enabled:\n            await initialize(bot)\n\n    @bot.event\n    async def on_error(event_method, *args, **kwargs):\n        sentry_log.exception(\"Exception in {}\".format(event_method))\n\n    @bot.event\n    async def on_command_error(ctx, error):\n        if isinstance(error, commands.MissingRequiredArgument):\n            await ctx.send_help()\n        elif isinstance(error, commands.BadArgument):\n            await ctx.send_help()\n        elif isinstance(error, commands.DisabledCommand):\n            await ctx.send(\"That command is disabled.\")\n        elif isinstance(error, commands.CommandInvokeError):\n            # Need to test if the following still works\n            \"\"\"\n            no_dms = \"Cannot send messages to this user\"\n            is_help_cmd = ctx.command.qualified_name == \"help\"\n            is_forbidden = isinstance(error.original, discord.Forbidden)\n            if is_help_cmd and is_forbidden and error.original.text == no_dms:\n                msg = (\"I couldn't send the help message to you in DM. Either\"\n                       \" you blocked me or you disabled DMs in this server.\")\n                await ctx.send(msg)\n                return\n            \"\"\"\n            log.exception(\"Exception in command '{}'\"\n                          \"\".format(ctx.command.qualified_name),\n                          exc_info=error.original)\n            sentry_log.exception(\"Exception in command '{}'\"\n                                 \"\".format(ctx.command.qualified_name),\n                                 exc_info=error.original)\n\n            message = (\"Error in command '{}'. Check your console or \"\n                       \"logs for details.\"\n                       \"\".format(ctx.command.qualified_name))\n            exception_log = (\"Exception in command '{}'\\n\"\n                             \"\".format(ctx.command.qualified_name))\n            exception_log += \"\".join(traceback.format_exception(type(error),\n                                     error, error.__traceback__))\n            bot._last_exception = exception_log\n            await ctx.send(inline(message))\n        elif isinstance(error, commands.CommandNotFound):\n            pass\n        elif isinstance(error, commands.CheckFailure):\n            await ctx.send(\"\u26d4 You are not authorized to issue that command.\")\n        elif isinstance(error, commands.NoPrivateMessage):\n            await ctx.send(\"That command is not available in DMs.\")\n        elif isinstance(error, commands.CommandOnCooldown):\n            await ctx.send(\"This command is on cooldown. \"\n                           \"Try again in {:.2f}s\"\n                           \"\".format(error.retry_after))\n        else:\n            log.exception(type(error).__name__, exc_info=error)\n            try:\n                sentry_error = error.original\n            except AttributeError:\n                sentry_error = error\n\n            sentry_log.exception(\"Unhandled command error.\",\n                                 exc_info=sentry_error)\n\n    @bot.event\n    async def on_message(message):\n        bot.counter[\"messages_read\"] += 1\n        await bot.process_commands(message)\n\n    @bot.event\n    async def on_resumed():\n        bot.counter[\"sessions_resumed\"] += 1\n\n    @bot.event\n    async def on_command(command):\n        bot.counter[\"processed_commands\"] += 1\n\ndef _get_settings_symbols():\n    \"\"\"Get symbols for displaying settings on stdout.\n\n    This is so we don't get encoding errors when trying to print unicode\n    emojis to stdout (particularly with Windows Command Prompt).\n    \"\"\"\n    encoder = codecs.getencoder(sys.stdout.encoding)\n    check_mark = \"\\N{SQUARE ROOT}\"\n    try:\n        encoder(check_mark)\n    except UnicodeEncodeError:\n        on_symbol = \"[X]\"\n        off_symbol = \"[ ]\"\n    else:\n        on_symbol = check_mark\n        off_symbol = \"X\"\n\n    return on_symbol, off_symbol\n", "path": "redbot/core/events.py"}]}