Fixed it so all moderators can now see incidents reported by others
This commit is contained in:
		@@ -228,12 +228,14 @@ async def setup(client):
 | 
				
			|||||||
                for msg in incident['messages']
 | 
					                for msg in incident['messages']
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            moderator = await interaction.guild.fetch_member(incident['details']['moderator_id'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            embed = discord.Embed(
 | 
					            embed = discord.Embed(
 | 
				
			||||||
                title=f"Incident {incident_id}",
 | 
					                title=f"Incident {incident_id}",
 | 
				
			||||||
                description=(
 | 
					                description=(
 | 
				
			||||||
                    f"**Reason:** {incident['details']['reason']}\n"
 | 
					                    f"**Reason:** {incident['details']['reason']}\n"
 | 
				
			||||||
                    f"**Capture Mode:** {incident['details']['capture_mode'].title()}\n"
 | 
					                    f"**Logged by:** {moderator.mention}\n"
 | 
				
			||||||
                    f"**Params:** {incident['details']['capture_param']}"
 | 
					                    f"**When:** <t:{int(incident['details']['timestamp'].timestamp())}:F>"
 | 
				
			||||||
                ),
 | 
					                ),
 | 
				
			||||||
                color=0xff0000
 | 
					                color=0xff0000
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
@@ -262,10 +264,14 @@ async def setup(client):
 | 
				
			|||||||
        interaction: discord.Interaction,
 | 
					        interaction: discord.Interaction,
 | 
				
			||||||
        current: str
 | 
					        current: str
 | 
				
			||||||
    ) -> List[app_commands.Choice[str]]:
 | 
					    ) -> List[app_commands.Choice[str]]:
 | 
				
			||||||
        incidents = db.get_recent_incidents(interaction.user.id, 25)
 | 
					        # Changed to get all incidents, not just current mod's
 | 
				
			||||||
 | 
					        incidents = db.get_recent_incidents(25)
 | 
				
			||||||
        return [
 | 
					        return [
 | 
				
			||||||
            app_commands.Choice(name=inc["id"], value=inc["id"])
 | 
					            app_commands.Choice(
 | 
				
			||||||
            for inc in incidents if current.lower() in inc["id"].lower()
 | 
					                name=f"{inc['id']} (by {await interaction.guild.fetch_member(inc['moderator_id'])})",
 | 
				
			||||||
 | 
					                value=inc['id']
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
 | 
					            for inc in incidents if current.lower() in inc['id'].lower()
 | 
				
			||||||
        ][:25]
 | 
					        ][:25]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    client.tree.add_command(moments_group)
 | 
					    client.tree.add_command(moments_group)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -143,14 +143,14 @@ class Database:
 | 
				
			|||||||
                "messages": [dict(msg) for msg in messages]
 | 
					                "messages": [dict(msg) for msg in messages]
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_recent_incidents(self, moderator_id: int, limit: int = 25):
 | 
					    def get_recent_incidents(self, limit: int = 25):
 | 
				
			||||||
 | 
					        """Get all recent incidents (not limited to current moderator)"""
 | 
				
			||||||
        with self._get_connection() as conn:
 | 
					        with self._get_connection() as conn:
 | 
				
			||||||
            conn.row_factory = sqlite3.Row
 | 
					            conn.row_factory = sqlite3.Row
 | 
				
			||||||
            cursor = conn.cursor()
 | 
					            cursor = conn.cursor()
 | 
				
			||||||
            cursor.execute("""
 | 
					            cursor.execute("""
 | 
				
			||||||
                SELECT id FROM incidents
 | 
					                SELECT id, moderator_id FROM incidents
 | 
				
			||||||
                WHERE moderator_id = ?
 | 
					 | 
				
			||||||
                ORDER BY timestamp DESC
 | 
					                ORDER BY timestamp DESC
 | 
				
			||||||
                LIMIT ?
 | 
					                LIMIT ?
 | 
				
			||||||
            """, (moderator_id, limit))
 | 
					            """, (limit,))
 | 
				
			||||||
            return [dict(row) for row in cursor.fetchall()]
 | 
					            return [dict(row) for row in cursor.fetchall()]
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user