Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ban updates2.0 #2293

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Ban updates2.0 #2293

wants to merge 12 commits into from

Conversation

TitanVJ
Copy link
Contributor

@TitanVJ TitanVJ commented Feb 2, 2025

Description

  • ban() now uses guild.ban() to facilitate clearing messages because its instant and the slowness of the previous method was not liked. also sometimes the clearing of messages just wouldn't work
  • intercept updated to use halting problem to capture audit log data, will reduce the number of failures if discord takes longer to generate the audit entry
  • removed all intermediate message, prevents clutter from mod report channel
  • all responses are sent to mod channel instead of responding to the interaction
  • updated default ban reason
  • embed utility was dropped for most commands in Ban, was unnecessary for most of the embeds since they're deterministic in size
  • no more getting discrimintors for users since they were phased out last year, now pulling from user.name()

@TitanVJ TitanVJ requested a review from a team as a code owner February 2, 2025 19:56
@TitanVJ
Copy link
Contributor Author

TitanVJ commented Feb 2, 2025

@modernNeo

Seems my first branch has some commits from master that've since been removed. So I made this fresh branch and cherry picked my commits over.

Copy link
Member

@modernNeo modernNeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add the embed helper back. the checks against the text sizes was just 1 thing it does. hint take a look at line of code under 180 on embed.py

@modernNeo modernNeo force-pushed the master branch 14 times, most recently from ef91068 to 41712f3 Compare March 1, 2025 21:41
@modernNeo modernNeo force-pushed the master branch 4 times, most recently from 08e135d to 2bc735e Compare March 1, 2025 22:33
@TitanVJ
Copy link
Contributor Author

TitanVJ commented Mar 5, 2025

please add the embed helper back. the checks against the text sizes was just 1 thing it does. hint take a look at line of code under 180 on embed.py

The embeds in ban that I changed don't set author or author icon, so there's no need for the utility.

@TitanVJ
Copy link
Contributor Author

TitanVJ commented Mar 5, 2025

Not using the embed utilitiy function made the code simpler plus its faster:

Run # 1
discord.Embed avg time: 0.0000404119
utility.embed avg time: 0.0001147270
discord.Embed is 2.8389 times faster than utility.embed

Run # 2
discord.Embed avg time: 0.0000305653
utility.embed avg time: 0.0001038313
discord.Embed is 3.3970 times faster than utility.embed

Run # 3
discord.Embed avg time: 0.0000303030
utility.embed avg time: 0.0000788689
discord.Embed is 2.6027 times faster than utility.embed

Run # 4
discord.Embed avg time: 0.0000374556
utility.embed avg time: 0.0000818253
discord.Embed is 2.1846 times faster than utility.embed

Run # 5
discord.Embed avg time: 0.0000367880
utility.embed avg time: 0.0000920296
discord.Embed is 2.5016 times faster than utility.embed

Run # 6
discord.Embed avg time: 0.0000489712
utility.embed avg time: 0.0000953436
discord.Embed is 1.9469 times faster than utility.embed

Run # 7
discord.Embed avg time: 0.0000379562
utility.embed avg time: 0.0000935793
discord.Embed is 2.4655 times faster than utility.embed

Run # 8
discord.Embed avg time: 0.0000402689
utility.embed avg time: 0.0000868082
discord.Embed is 2.1557 times faster than utility.embed

Run # 9
discord.Embed avg time: 0.0000540733
utility.embed avg time: 0.0001094818
discord.Embed is 2.0247 times faster than utility.embed

Run # 10
discord.Embed avg time: 0.0000351906
utility.embed avg time: 0.0001027107
discord.Embed is 2.9187 times faster than utility.embed

Fast Factors
[ 2.8389, 3.3970, 2.6027, 2.1846, 2.5016, 1.9469, 2.4655, 2.1557, 2.0247, 2.9187]
Avg: 2.5036

@TitanVJ
Copy link
Contributor Author

TitanVJ commented Mar 5, 2025

code i used for the tests. called .go 10. measures time for creation of embed.

    @commands.command()
    async def go(self, ctx, num: int):
        times = [0 for _ in range(1, num+1)]
        for idx in range(1, num+1):
            await ctx.send(f"**Run #{idx}**")
            times[idx-1] = await self.time(ctx)
        avg = sum(times)/num
        times = (
            "**Fast Factor**\n"
            f"[ {', '.join([f'{t:.4f}' for t in times])}]\n"
            f"Avg: {avg:.4f}"
        )
        await ctx.send(times)

    @commands.command()
    async def time(self, ctx):
        times = [0 for _ in range(1, 11)]
        times2 = [0 for _ in range(1, 11)]
        ban_date = pstdatetime.now()

        for idx in range(1, 11):
            start = time.time()
            e_obj = discord.Embed(title=f"Time testing #{idx}", color=discord.Color.red())
            e_obj.add_field(name="Banned User", value=f"**Username**")
            e_obj.add_field(name="Moderator", value=f"**Mod Name**")
            e_obj.add_field(name="Reason", value=f"```Ban Reason```", inline=False)
            e_obj.add_field(name="User Notified via DM", value="No", inline=False)
            e_obj.set_footer(text="Moderator Action")
            e_obj.timestamp = ban_date
            end = time.time()

            times[idx-1] = end - start
            await asyncio.sleep(1)

        for idx in range(1, 11):
            start = time.time()
            content = [
                ("Banned User", "**Username**", True),
                ("Moderator", "**Mod Name**", True),
                ("Reason", "```Ban Reason```", False),
                ("User Notified via DM", "No", False)
            ]
            e_obj = await embed(
                logger=self.logger,
                ctx=ctx,
                title=f"Time testing #{idx}",
                colour=WallEColour.ERROR,
                content=content,
                footer_text="Moderator Action",
                timestamp=ban_date
            )
            if e_obj:
                end = time.time()
            times2[idx - 1] = end - start
            await asyncio.sleep(1)

        av1 = sum(times)/10
        av2 = sum(times2)/10
        fast = av2/av1
        await ctx.send(
            (f"discord.Embed avg time: `{av1:.10f}`\n"
             f"utility.embed avg time:     `{av2:.10f}`\n"
             f"discord.Embed is `{fast:.4f}` times faster than utility.embed")
        )
        return fast

Copy link
Member

@modernNeo modernNeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the wall_e embed utility to ensure consistency and then I will take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants