Repository: Cog-Creators/Red-DiscordBot

Issue:
[V3] Warnings cog issue
# Command bugs

<!-- 
Did you find a bug with a command? Fill out the following:
-->

#### Command name

.warn

#### What cog is this command from?

Warnings

#### What were you expecting to happen?

When a user goes above the points threshold, the assigned action should occur.

#### What actually happened?

User gets warned and points get added however no action is issued.

#### How can we reproduce this issue?

Create a warnreason, assign it a point value and set that point value to ban a user.
 Then warn the user.

Here's an example of what I have setup and the bot has done nothing to the user

http://evac.gg/i/pthl6.png

When setting up the action, i used:

ban {user}




Discussion:
Seems to be an issue with the mod cog not the warning cog. Entering the command myself +ban someusername gives a hierarchy error even if i turn off that check with modset heiarchy
@useruser3 Not related to the mod cog. I cannot reproduce the behavior you are describing.

I **also** cannot reproduce a lack of warning actions actually being triggered.
@evacfk try restarting your bot. Resolved it for me
Did not resolve for me.
On Sep 8, 2018, 3:51 AM -0700, useruser3 <notifications@github.com>, wrote:
> @evacfk try restarting your bot. Resolved it for me
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub, or mute the thread.

I'm able to reproduce this.
Updated to B21 and same issue exists. I've tried restarting bot, reloading warnings.

I don't see any errors, on bot startup I get 

"Unknown event GUILD_INTEGRATIONS_UPDATE."

But that's it.
That message is a discord.py issue (see Rapptz/discord.py/issues/1083)
I also have the problem with the warning and also with the hierarchy

Some more info to the problem:
I have two roles for my V3: `SauriBot` and `Owner's Baby Bots`, where the second one is there purely just so the bot appears below Verified members while the first role is all the way above everyone (and is the one with all permissions). I also have set that after 3 warnings (= 3 points), the user shall be kicked out and if rejoined, after another one (4 points in total), the user shall be banned from the server. This, however, does not happen, [as seen here](https://cdn.discordapp.com/attachments/387398816317440000/492025505369948162/cats.jpg). Also, the manual kick and ban with `[p]kick <user>` and `[p]ban <user>` give me an error whenever the user has higher role than `Owner's Baby Bots`, even tho it's below `SauriBot`, [as seen here](https://cdn.discordapp.com/attachments/387398816317440000/492025514064609280/cats2.jpg).

Those two basically go hand in hand together as the bot cannot kick the person, [as seen here](https://cdn.discordapp.com/attachments/483402230540533770/494545337290063872/unknown.png) (tried it right now with my second account).

Resolving patch:
diff --git a/redbot/cogs/warnings/helpers.py b/redbot/cogs/warnings/helpers.py
--- a/redbot/cogs/warnings/helpers.py
+++ b/redbot/cogs/warnings/helpers.py
@@ -19,9 +19,11 @@ async def warning_points_add_check(
     act = {}
     async with guild_settings.actions() as registered_actions:
         for a in registered_actions:
+            # Actions are sorted in decreasing order of points.
+            # The first action we find where the user is above the threshold will be the
+            # highest action we can take.
             if points >= a["points"]:
                 act = a
-            else:
                 break
     if act and act["exceed_command"] is not None:  # some action needs to be taken
         await create_and_invoke_context(ctx, act["exceed_command"], user)
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
@@ -9,7 +9,7 @@
     get_command_for_dropping_points,
     warning_points_remove_check,
 )
-from redbot.core import Config, modlog, checks, commands
+from redbot.core import Config, checks, commands
 from redbot.core.bot import Red
 from redbot.core.i18n import Translator, cog_i18n
 from redbot.core.utils.mod import is_admin_or_superior
@@ -34,15 +34,14 @@ def __init__(self, bot: Red):
         self.config.register_guild(**self.default_guild)
         self.config.register_member(**self.default_member)
         self.bot = bot
-        loop = asyncio.get_event_loop()
-        loop.create_task(self.register_warningtype())
 
-    @staticmethod
-    async def register_warningtype():
-        try:
-            await modlog.register_casetype("warning", True, "\N{WARNING SIGN}", "Warning", None)
-        except RuntimeError:
-            pass
+    # We're not utilising modlog yet - no need to register a casetype
+    # @staticmethod
+    # async def register_warningtype():
+    #     try:
+    #         await modlog.register_casetype("warning", True, "\N{WARNING SIGN}", "Warning", None)
+    #     except RuntimeError:
+    #         pass
 
     @commands.group()
     @commands.guild_only()


Test patch: