We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Disable all bot commands but !accept in checkpoint
**Originally posted by ByteCommander:**

The #checkpoint channel is where new members have to go to type `!accept` in order to verify they have read the rules and to get access to all other public channels.

Currently, the bot removes all user messages from #checkpoint immediately, to keep it clean. If the user types anything other than `!accept`, they additionally get a warning which self-destructs after short time.

However, other bot commands are still working, and while the user's original command message will be removed, any command responses will still get posted and do not seem to ever get deleted automatically.

![image](https://cdn.discordapp.com/attachments/464905259261755392/503172538910638110/Screenshot_from_2018-10-20_13-46-45.png)

This seems to be a bug that allows people spamming the checkpoint channel to annoy yet to be verified users.

As a solution, all commands except for `!accept` should be entirely disabled in #checkpoint.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `bot/cogs/verification.py`
Content:
```
1 import logging
2 
3 from discord import Message, NotFound, Object
4 from discord.ext.commands import Bot, Context, command
5 
6 from bot.cogs.modlog import ModLog
7 from bot.constants import Channels, Event, Roles
8 from bot.decorators import in_channel, without_role
9 
10 log = logging.getLogger(__name__)
11 
12 WELCOME_MESSAGE = f"""
13 Hello! Welcome to the server, and thanks for verifying yourself!
14 
15 For your records, these are the documents you accepted:
16 
17 `1)` Our rules, here: <https://pythondiscord.com/about/rules>
18 `2)` Our privacy policy, here: <https://pythondiscord.com/about/privacy> - you can find information on how to have \
19 your information removed here as well.
20 
21 Feel free to review them at any point!
22 
23 Additionally, if you'd like to receive notifications for the announcements we post in <#{Channels.announcements}> \
24 from time to time, you can send `!subscribe` to <#{Channels.bot}> at any time to assign yourself the \
25 **Announcements** role. We'll mention this role every time we make an announcement.
26 
27 If you'd like to unsubscribe from the announcement notifications, simply send `!unsubscribe` to <#{Channels.bot}>.
28 """
29 
30 
31 class Verification:
32     """
33     User verification and role self-management
34     """
35 
36     def __init__(self, bot: Bot):
37         self.bot = bot
38 
39     @property
40     def mod_log(self) -> ModLog:
41         return self.bot.get_cog("ModLog")
42 
43     async def on_message(self, message: Message):
44         if message.author.bot:
45             return  # They're a bot, ignore
46 
47         ctx = await self.bot.get_context(message)  # type: Context
48 
49         if ctx.command is not None and ctx.command.name == "accept":
50             return  # They used the accept command
51 
52         if ctx.channel.id == Channels.verification:  # We're in the verification channel
53             for role in ctx.author.roles:
54                 if role.id == Roles.verified:
55                     log.warning(f"{ctx.author} posted '{ctx.message.content}' "
56                                 "in the verification channel, but is already verified.")
57                     return  # They're already verified
58 
59             log.debug(f"{ctx.author} posted '{ctx.message.content}' in the verification "
60                       "channel. We are providing instructions how to verify.")
61             await ctx.send(
62                 f"{ctx.author.mention} Please type `!accept` to verify that you accept our rules, "
63                 f"and gain access to the rest of the server.",
64                 delete_after=20
65             )
66 
67             log.trace(f"Deleting the message posted by {ctx.author}")
68 
69             try:
70                 await ctx.message.delete()
71             except NotFound:
72                 log.trace("No message found, it must have been deleted by another bot.")
73 
74     @command(name='accept', aliases=('verify', 'verified', 'accepted'), hidden=True)
75     @without_role(Roles.verified)
76     @in_channel(Channels.verification)
77     async def accept_command(self, ctx: Context, *_):  # We don't actually care about the args
78         """
79         Accept our rules and gain access to the rest of the server
80         """
81 
82         log.debug(f"{ctx.author} called !accept. Assigning the 'Developer' role.")
83         await ctx.author.add_roles(Object(Roles.verified), reason="Accepted the rules")
84         try:
85             await ctx.author.send(WELCOME_MESSAGE)
86         except Exception:
87             # Catch the exception, in case they have DMs off or something
88             log.exception(f"Unable to send welcome message to user {ctx.author}.")
89 
90         log.trace(f"Deleting the message posted by {ctx.author}.")
91 
92         try:
93             self.mod_log.ignore(Event.message_delete, ctx.message.id)
94             await ctx.message.delete()
95         except NotFound:
96             log.trace("No message found, it must have been deleted by another bot.")
97 
98     @command(name='subscribe')
99     @in_channel(Channels.bot)
100     async def subscribe_command(self, ctx: Context, *_):  # We don't actually care about the args
101         """
102         Subscribe to announcement notifications by assigning yourself the role
103         """
104 
105         has_role = False
106 
107         for role in ctx.author.roles:
108             if role.id == Roles.announcements:
109                 has_role = True
110                 break
111 
112         if has_role:
113             return await ctx.send(
114                 f"{ctx.author.mention} You're already subscribed!",
115             )
116 
117         log.debug(f"{ctx.author} called !subscribe. Assigning the 'Announcements' role.")
118         await ctx.author.add_roles(Object(Roles.announcements), reason="Subscribed to announcements")
119 
120         log.trace(f"Deleting the message posted by {ctx.author}.")
121 
122         await ctx.send(
123             f"{ctx.author.mention} Subscribed to <#{Channels.announcements}> notifications.",
124         )
125 
126     @command(name='unsubscribe')
127     @in_channel(Channels.bot)
128     async def unsubscribe_command(self, ctx: Context, *_):  # We don't actually care about the args
129         """
130         Unsubscribe from announcement notifications by removing the role from yourself
131         """
132 
133         has_role = False
134 
135         for role in ctx.author.roles:
136             if role.id == Roles.announcements:
137                 has_role = True
138                 break
139 
140         if not has_role:
141             return await ctx.send(
142                 f"{ctx.author.mention} You're already unsubscribed!"
143             )
144 
145         log.debug(f"{ctx.author} called !unsubscribe. Removing the 'Announcements' role.")
146         await ctx.author.remove_roles(Object(Roles.announcements), reason="Unsubscribed from announcements")
147 
148         log.trace(f"Deleting the message posted by {ctx.author}.")
149 
150         await ctx.send(
151             f"{ctx.author.mention} Unsubscribed from <#{Channels.announcements}> notifications."
152         )
153 
154 
155 def setup(bot):
156     bot.add_cog(Verification(bot))
157     log.info("Cog loaded: Verification")
158
```
--- 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/bot/cogs/verification.py b/bot/cogs/verification.py
--- a/bot/cogs/verification.py
+++ b/bot/cogs/verification.py
@@ -151,6 +151,17 @@
             f"{ctx.author.mention} Unsubscribed from <#{Channels.announcements}> notifications."
         )
 
+    @staticmethod
+    def __global_check(ctx: Context):
+        """
+        Block any command within the verification channel that is not !accept.
+        """
+
+        if ctx.channel.id == Channels.verification:
+            return ctx.command.name == "accept"
+        else:
+            return True
+
 
 def setup(bot):
     bot.add_cog(Verification(bot))

{"golden_diff": "diff --git a/bot/cogs/verification.py b/bot/cogs/verification.py\n--- a/bot/cogs/verification.py\n+++ b/bot/cogs/verification.py\n@@ -151,6 +151,17 @@\n             f\"{ctx.author.mention} Unsubscribed from <#{Channels.announcements}> notifications.\"\n         )\n \n+    @staticmethod\n+    def __global_check(ctx: Context):\n+        \"\"\"\n+        Block any command within the verification channel that is not !accept.\n+        \"\"\"\n+\n+        if ctx.channel.id == Channels.verification:\n+            return ctx.command.name == \"accept\"\n+        else:\n+            return True\n+\n \n def setup(bot):\n     bot.add_cog(Verification(bot))\n", "issue": "Disable all bot commands but !accept in checkpoint\n**Originally posted by ByteCommander:**\n\nThe #checkpoint channel is where new members have to go to type `!accept` in order to verify they have read the rules and to get access to all other public channels.\n\nCurrently, the bot removes all user messages from #checkpoint immediately, to keep it clean. If the user types anything other than `!accept`, they additionally get a warning which self-destructs after short time.\n\nHowever, other bot commands are still working, and while the user's original command message will be removed, any command responses will still get posted and do not seem to ever get deleted automatically.\n\n![image](https://cdn.discordapp.com/attachments/464905259261755392/503172538910638110/Screenshot_from_2018-10-20_13-46-45.png)\n\nThis seems to be a bug that allows people spamming the checkpoint channel to annoy yet to be verified users.\n\nAs a solution, all commands except for `!accept` should be entirely disabled in #checkpoint.\n", "before_files": [{"content": "import logging\n\nfrom discord import Message, NotFound, Object\nfrom discord.ext.commands import Bot, Context, command\n\nfrom bot.cogs.modlog import ModLog\nfrom bot.constants import Channels, Event, Roles\nfrom bot.decorators import in_channel, without_role\n\nlog = logging.getLogger(__name__)\n\nWELCOME_MESSAGE = f\"\"\"\nHello! Welcome to the server, and thanks for verifying yourself!\n\nFor your records, these are the documents you accepted:\n\n`1)` Our rules, here: <https://pythondiscord.com/about/rules>\n`2)` Our privacy policy, here: <https://pythondiscord.com/about/privacy> - you can find information on how to have \\\nyour information removed here as well.\n\nFeel free to review them at any point!\n\nAdditionally, if you'd like to receive notifications for the announcements we post in <#{Channels.announcements}> \\\nfrom time to time, you can send `!subscribe` to <#{Channels.bot}> at any time to assign yourself the \\\n**Announcements** role. We'll mention this role every time we make an announcement.\n\nIf you'd like to unsubscribe from the announcement notifications, simply send `!unsubscribe` to <#{Channels.bot}>.\n\"\"\"\n\n\nclass Verification:\n    \"\"\"\n    User verification and role self-management\n    \"\"\"\n\n    def __init__(self, bot: Bot):\n        self.bot = bot\n\n    @property\n    def mod_log(self) -> ModLog:\n        return self.bot.get_cog(\"ModLog\")\n\n    async def on_message(self, message: Message):\n        if message.author.bot:\n            return  # They're a bot, ignore\n\n        ctx = await self.bot.get_context(message)  # type: Context\n\n        if ctx.command is not None and ctx.command.name == \"accept\":\n            return  # They used the accept command\n\n        if ctx.channel.id == Channels.verification:  # We're in the verification channel\n            for role in ctx.author.roles:\n                if role.id == Roles.verified:\n                    log.warning(f\"{ctx.author} posted '{ctx.message.content}' \"\n                                \"in the verification channel, but is already verified.\")\n                    return  # They're already verified\n\n            log.debug(f\"{ctx.author} posted '{ctx.message.content}' in the verification \"\n                      \"channel. We are providing instructions how to verify.\")\n            await ctx.send(\n                f\"{ctx.author.mention} Please type `!accept` to verify that you accept our rules, \"\n                f\"and gain access to the rest of the server.\",\n                delete_after=20\n            )\n\n            log.trace(f\"Deleting the message posted by {ctx.author}\")\n\n            try:\n                await ctx.message.delete()\n            except NotFound:\n                log.trace(\"No message found, it must have been deleted by another bot.\")\n\n    @command(name='accept', aliases=('verify', 'verified', 'accepted'), hidden=True)\n    @without_role(Roles.verified)\n    @in_channel(Channels.verification)\n    async def accept_command(self, ctx: Context, *_):  # We don't actually care about the args\n        \"\"\"\n        Accept our rules and gain access to the rest of the server\n        \"\"\"\n\n        log.debug(f\"{ctx.author} called !accept. Assigning the 'Developer' role.\")\n        await ctx.author.add_roles(Object(Roles.verified), reason=\"Accepted the rules\")\n        try:\n            await ctx.author.send(WELCOME_MESSAGE)\n        except Exception:\n            # Catch the exception, in case they have DMs off or something\n            log.exception(f\"Unable to send welcome message to user {ctx.author}.\")\n\n        log.trace(f\"Deleting the message posted by {ctx.author}.\")\n\n        try:\n            self.mod_log.ignore(Event.message_delete, ctx.message.id)\n            await ctx.message.delete()\n        except NotFound:\n            log.trace(\"No message found, it must have been deleted by another bot.\")\n\n    @command(name='subscribe')\n    @in_channel(Channels.bot)\n    async def subscribe_command(self, ctx: Context, *_):  # We don't actually care about the args\n        \"\"\"\n        Subscribe to announcement notifications by assigning yourself the role\n        \"\"\"\n\n        has_role = False\n\n        for role in ctx.author.roles:\n            if role.id == Roles.announcements:\n                has_role = True\n                break\n\n        if has_role:\n            return await ctx.send(\n                f\"{ctx.author.mention} You're already subscribed!\",\n            )\n\n        log.debug(f\"{ctx.author} called !subscribe. Assigning the 'Announcements' role.\")\n        await ctx.author.add_roles(Object(Roles.announcements), reason=\"Subscribed to announcements\")\n\n        log.trace(f\"Deleting the message posted by {ctx.author}.\")\n\n        await ctx.send(\n            f\"{ctx.author.mention} Subscribed to <#{Channels.announcements}> notifications.\",\n        )\n\n    @command(name='unsubscribe')\n    @in_channel(Channels.bot)\n    async def unsubscribe_command(self, ctx: Context, *_):  # We don't actually care about the args\n        \"\"\"\n        Unsubscribe from announcement notifications by removing the role from yourself\n        \"\"\"\n\n        has_role = False\n\n        for role in ctx.author.roles:\n            if role.id == Roles.announcements:\n                has_role = True\n                break\n\n        if not has_role:\n            return await ctx.send(\n                f\"{ctx.author.mention} You're already unsubscribed!\"\n            )\n\n        log.debug(f\"{ctx.author} called !unsubscribe. Removing the 'Announcements' role.\")\n        await ctx.author.remove_roles(Object(Roles.announcements), reason=\"Unsubscribed from announcements\")\n\n        log.trace(f\"Deleting the message posted by {ctx.author}.\")\n\n        await ctx.send(\n            f\"{ctx.author.mention} Unsubscribed from <#{Channels.announcements}> notifications.\"\n        )\n\n\ndef setup(bot):\n    bot.add_cog(Verification(bot))\n    log.info(\"Cog loaded: Verification\")\n", "path": "bot/cogs/verification.py"}], "after_files": [{"content": "import logging\n\nfrom discord import Message, NotFound, Object\nfrom discord.ext.commands import Bot, Context, command\n\nfrom bot.cogs.modlog import ModLog\nfrom bot.constants import Channels, Event, Roles\nfrom bot.decorators import in_channel, without_role\n\nlog = logging.getLogger(__name__)\n\nWELCOME_MESSAGE = f\"\"\"\nHello! Welcome to the server, and thanks for verifying yourself!\n\nFor your records, these are the documents you accepted:\n\n`1)` Our rules, here: <https://pythondiscord.com/about/rules>\n`2)` Our privacy policy, here: <https://pythondiscord.com/about/privacy> - you can find information on how to have \\\nyour information removed here as well.\n\nFeel free to review them at any point!\n\nAdditionally, if you'd like to receive notifications for the announcements we post in <#{Channels.announcements}> \\\nfrom time to time, you can send `!subscribe` to <#{Channels.bot}> at any time to assign yourself the \\\n**Announcements** role. We'll mention this role every time we make an announcement.\n\nIf you'd like to unsubscribe from the announcement notifications, simply send `!unsubscribe` to <#{Channels.bot}>.\n\"\"\"\n\n\nclass Verification:\n    \"\"\"\n    User verification and role self-management\n    \"\"\"\n\n    def __init__(self, bot: Bot):\n        self.bot = bot\n\n    @property\n    def mod_log(self) -> ModLog:\n        return self.bot.get_cog(\"ModLog\")\n\n    async def on_message(self, message: Message):\n        if message.author.bot:\n            return  # They're a bot, ignore\n\n        ctx = await self.bot.get_context(message)  # type: Context\n\n        if ctx.command is not None and ctx.command.name == \"accept\":\n            return  # They used the accept command\n\n        if ctx.channel.id == Channels.verification:  # We're in the verification channel\n            for role in ctx.author.roles:\n                if role.id == Roles.verified:\n                    log.warning(f\"{ctx.author} posted '{ctx.message.content}' \"\n                                \"in the verification channel, but is already verified.\")\n                    return  # They're already verified\n\n            log.debug(f\"{ctx.author} posted '{ctx.message.content}' in the verification \"\n                      \"channel. We are providing instructions how to verify.\")\n            await ctx.send(\n                f\"{ctx.author.mention} Please type `!accept` to verify that you accept our rules, \"\n                f\"and gain access to the rest of the server.\",\n                delete_after=20\n            )\n\n            log.trace(f\"Deleting the message posted by {ctx.author}\")\n\n            try:\n                await ctx.message.delete()\n            except NotFound:\n                log.trace(\"No message found, it must have been deleted by another bot.\")\n\n    @command(name='accept', aliases=('verify', 'verified', 'accepted'), hidden=True)\n    @without_role(Roles.verified)\n    @in_channel(Channels.verification)\n    async def accept_command(self, ctx: Context, *_):  # We don't actually care about the args\n        \"\"\"\n        Accept our rules and gain access to the rest of the server\n        \"\"\"\n\n        log.debug(f\"{ctx.author} called !accept. Assigning the 'Developer' role.\")\n        await ctx.author.add_roles(Object(Roles.verified), reason=\"Accepted the rules\")\n        try:\n            await ctx.author.send(WELCOME_MESSAGE)\n        except Exception:\n            # Catch the exception, in case they have DMs off or something\n            log.exception(f\"Unable to send welcome message to user {ctx.author}.\")\n\n        log.trace(f\"Deleting the message posted by {ctx.author}.\")\n\n        try:\n            self.mod_log.ignore(Event.message_delete, ctx.message.id)\n            await ctx.message.delete()\n        except NotFound:\n            log.trace(\"No message found, it must have been deleted by another bot.\")\n\n    @command(name='subscribe')\n    @in_channel(Channels.bot)\n    async def subscribe_command(self, ctx: Context, *_):  # We don't actually care about the args\n        \"\"\"\n        Subscribe to announcement notifications by assigning yourself the role\n        \"\"\"\n\n        has_role = False\n\n        for role in ctx.author.roles:\n            if role.id == Roles.announcements:\n                has_role = True\n                break\n\n        if has_role:\n            return await ctx.send(\n                f\"{ctx.author.mention} You're already subscribed!\",\n            )\n\n        log.debug(f\"{ctx.author} called !subscribe. Assigning the 'Announcements' role.\")\n        await ctx.author.add_roles(Object(Roles.announcements), reason=\"Subscribed to announcements\")\n\n        log.trace(f\"Deleting the message posted by {ctx.author}.\")\n\n        await ctx.send(\n            f\"{ctx.author.mention} Subscribed to <#{Channels.announcements}> notifications.\",\n        )\n\n    @command(name='unsubscribe')\n    @in_channel(Channels.bot)\n    async def unsubscribe_command(self, ctx: Context, *_):  # We don't actually care about the args\n        \"\"\"\n        Unsubscribe from announcement notifications by removing the role from yourself\n        \"\"\"\n\n        has_role = False\n\n        for role in ctx.author.roles:\n            if role.id == Roles.announcements:\n                has_role = True\n                break\n\n        if not has_role:\n            return await ctx.send(\n                f\"{ctx.author.mention} You're already unsubscribed!\"\n            )\n\n        log.debug(f\"{ctx.author} called !unsubscribe. Removing the 'Announcements' role.\")\n        await ctx.author.remove_roles(Object(Roles.announcements), reason=\"Unsubscribed from announcements\")\n\n        log.trace(f\"Deleting the message posted by {ctx.author}.\")\n\n        await ctx.send(\n            f\"{ctx.author.mention} Unsubscribed from <#{Channels.announcements}> notifications.\"\n        )\n\n    @staticmethod\n    def __global_check(ctx: Context):\n        \"\"\"\n        Block any command within the verification channel that is not !accept.\n        \"\"\"\n\n        if ctx.channel.id == Channels.verification:\n            return ctx.command.name == \"accept\"\n        else:\n            return True\n\n\ndef setup(bot):\n    bot.add_cog(Verification(bot))\n    log.info(\"Cog loaded: Verification\")\n", "path": "bot/cogs/verification.py"}]}