junepark678 / GIRRewrite

Consider using in PYL-R1714
Performance
Major
a year agoa year old
Consider merging these comparisons with 'in' by using 'record.levelname in ('ERROR', 'CRITICAL')'. Use a set instead if elements are hashable.
105        for i, part in enumerate(parts):
106            content = f"{self.prefixcalc(record.levelname)}{part}{self.suffixcalc(record.levelname)}"
107            if i == len(parts) - 1:
108                if record.levelname == 'ERROR' or record.levelname == 'CRITICAL':109                    content += f'<@{os.environ.get("OWNER_ID")}>'
110            message_body = {
111                "content": content
Consider merging these comparisons with 'in' by using 'case._type in ('WARN', 'LIFTWARN')'. Use a set instead if elements are hashable.
134            for case in entries:
135                timestamp = case.date
136                formatted = f"{format_dt(timestamp, style='F')} ({format_dt(timestamp, style='R')})"
137                if case._type == "WARN" or case._type == "LIFTWARN":138                    if case.lifted:
139                        embed.add_field(
140                            name=f'{determine_emoji(case._type)} Case #{case._id} [LIFTED]', value=f'**Points**: {case.punishment}\n**Reason**: {case.reason}\n**Lifted by**: {case.lifted_by_tag}\n**Lift reason**: {case.lifted_reason}\n**Warned on**: {formatted}', inline=True)
Consider merging these comparisons with 'in' by using 'case._type in ('MUTE', 'REMOVEPOINTS')'. Use a set instead if elements are hashable.
144                    else:
145                        embed.add_field(name=f'{determine_emoji(case._type)} Case #{case._id}',
146                                        value=f'**Points**: {case.punishment}\n**Reason**: {case.reason}\n**Moderator**: {case.mod_tag}\n**Warned on**: {formatted}', inline=True)
147                elif case._type == "MUTE" or case._type == "REMOVEPOINTS":148                    embed.add_field(name=f'{determine_emoji(case._type)} Case #{case._id}',
149                                    value=f'**{pun_map[case._type]}**: {case.punishment}\n**Reason**: {case.reason}\n**Moderator**: {case.mod_tag}\n**Time**: {formatted}', inline=True)
150                elif case._type in pun_map:
Consider merging these comparisons with 'in' by using 'case._type in ('MUTE', 'REMOVEPOINTS')'. Use a set instead if elements are hashable.
 92            else:
 93                embed.add_field(name=f'{determine_emoji(case._type)} Case #{case._id}',
 94                                value=f'**Points**: {case.punishment}\n**Reason**: {case.reason}\n**Moderator**: {case.mod_tag}\n**Warned on**: {formatted}', inline=True)
 95        elif case._type == "MUTE" or case._type == "REMOVEPOINTS": 96            embed.add_field(name=f'{determine_emoji(case._type)} Case #{case._id}',
 97                            value=f'**{pun_map[case._type]}**: {case.punishment}\n**Reason**: {case.reason}\n**Moderator**: {case.mod_tag}\n**Time**: {formatted}', inline=True)
 98        elif case._type in pun_map:
Consider merging these comparisons with 'in' by using 'case._type in ('WARN', 'LIFTWARN')'. Use a set instead if elements are hashable.
 82    for case in entries:
 83        timestamp = case.date
 84        formatted = f"{format_dt(timestamp, style='F')} ({format_dt(timestamp, style='R')})"
 85        if case._type == "WARN" or case._type == "LIFTWARN": 86            if case.lifted:
 87                embed.add_field(name=f'{determine_emoji(case._type)} Case #{case._id} [LIFTED]',
 88                                value=f'**Points**: {case.punishment}\n**Reason**: {case.reason}\n**Lifted by**: {case.lifted_by_tag}\n**Lift reason**: {case.lifted_reason}\n**Warned on**: {formatted}', inline=True)