• Sjmarf
      link
      fedilink
      English
      1004 days ago

      For your viewing pleasure:

      for entry in entries:
          if entry['time'] + 1800 < time():
              guild = self._bot.get_guild(int(entry['guild_id']))
              member = guild.get_member(int(entry['user_id']))
              if member is not None:
                  if member.activity.name is not None:
                      if member.activity.name.lower() == "league of legends":
                          await member.send("The 30 minutes has elapsed and you are still playing league, get banned.")
                          await member.ban(delete_message_days=0, reason='playing league')
      
    • @ximtor@lemm.ee
      link
      fedilink
      53 days ago

      Thats not true!! I used to have fun! At least 4 games in 2000+ over 12 years were definitely fun!!

  • @Pnut@lemm.ee
    link
    fedilink
    484 days ago

    I had a roomie that played lol. After a month of not having a job and looking very scruffy he emerged from his filthy bedroom and gave me a grocery list. We were on good terms until I told him he had an addiction.

      • Kogasa
        link
        fedilink
        63 days ago

        It’s got a very high barrier to entry. You kinda have to suffer through it for a while before you get it. And then you unlock a totally different kind of suffering.

    • @Cenotaph@mander.xyz
      link
      fedilink
      English
      924 days ago

      Discord has a feature that broadcasts games you play to your friends at all times, and many people leave the feature on.

      • @chatokun@lemmy.dbzer0.com
        link
        fedilink
        3
        edit-2
        3 days ago

        I turned em off when my boss at the time noticed I was always playing FFXIV. I wasn’t always actually playing, I used to leave it open almost all the time. Why was my boss and I in the same discord? This was early COVID and we used a discord to shoot the shit. Also almost all of us gamed, including said boss, and I probably wouldn’t have really gotten in trouble anyway, but I just explained I leave it open a lot and he accepted that without qualm.

      • thermal_shock
        link
        fedilink
        English
        1
        edit-2
        3 days ago

        Oh, this is more people showing what they’re playing than actually playing the game. Lol

        • @Cenotaph@mander.xyz
          link
          fedilink
          English
          23 days ago

          Yes. Discord does have a screen-sharing feature but the one I was talking about is more of a “now playing”

      • @Nindelofocho@lemmy.world
        link
        fedilink
        English
        13 days ago

        I think its called Discord Rich Presence? If anyone is looking to turn it off. I think you can turn it off for specific games too

    • @Jankatarch@lemmy.world
      link
      fedilink
      24
      edit-2
      4 days ago

      There are two types of programmers.

      // comment
      if(condition) {
        // comment1
        if(condition1) {
          // comment2
          if(condition2) {
            printf("hello, world\\n");
          }
        }
      }
      

      and

      // comment
      if(!condition) {
        return;
      }
      
      // comment1
      if(!condition1) {
        return;
      }
      
      // comment2
      if(!condition2) {
        return;
      }
      
      printf("hello, world\\n");
      

      And one is objectively correct.

        • @kernelle@0d.gs
          link
          fedilink
          63 days ago

          The problem with this in the OP is the first ‘if’ checks if the object exists and the second gets a property of said object only if the original object exists.

          I’m not saying the OP is good code, but chaining them like this would result in exceptions.

          • Fushuan [he/him]
            link
            fedilink
            43 days ago

            The language is python and it has short circuiting aka in an and condition, if the first block isn’t fulfilled the second one isn’t tested because it’s unnecessary.

            Same with or and the reverse.

      • VeganPizza69 Ⓥ
        link
        fedilink
        33 days ago

        Add the else branches to the nested version and log the failed conditions (to make it more obvious).

      • I Cast Fist
        link
        fedilink
        84 days ago
        // comment
        if(x < 10) {
          // comment1
          if(x < 20) {
            // comment2
            if(x < 30) {
              printf("hello, world\\n");
            }
          }
        }
        
        • @underscores@lemmy.zip
          link
          fedilink
          English
          4
          edit-2
          4 days ago

          This is the cursed case when you case the forbidden scroll of the ancients: switch (true) { }

          edit: on second thought I’m not sure now I’ll have to think about how fall through cases work

    • @CannedYeet@lemmy.world
      link
      fedilink
      1
      edit-2
      2 days ago

      I worked with chatgpt since I’m not a python dev, and this is what I came up with

      from time import time
      
      class PlaySession:
          def __init__(self, data: dict):
              self.guild_id = int(data['guild_id'])
              self.user_id = int(data['user_id'])
              self.timestamp = data['time']
      
          def is_longer_than_half_hour(self) -> bool:
              return self.timestamp + 1800 < time()
      
          async def resolve_member(self, bot) -> "discord.Member | None":
              guild = bot.get_guild(self.guild_id)
              return guild.get_member(self.user_id) if guild else None
      
          @staticmethod
          def is_playing_league(member) -> bool:
              activity = getattr(member, 'activity', None)
              name = getattr(activity, 'name', None)
              return name and name.lower() == "league of legends"
      
      async def ban_for_league(member):
          await member.send("The 30 minutes has elapsed and you are still playing league, get banned.")
          await member.ban(delete_message_days=0, reason="playing league")
      
      async def process_entries(bot, entry_dicts):
          sessions = [PlaySession(d) for d in entry_dicts if PlaySession(d).is_longer_than_half_hour()]
          for session in sessions:
              member = await session.resolve_member(bot)
              if member and PlaySession.is_playing_league(member):
                  await ban_for_league(member)
      
    • @Tja@programming.dev
      link
      fedilink
      3
      edit-2
      3 days ago

      Not only nested ifs. It’s not even correct (doesn’t check for activity existing). And it’s not even pythonic (ask for forgiveness, not for permission). Just access the thing, catch the exception and be done with it.

    • @REDACTED@infosec.pub
      link
      fedilink
      English
      14 days ago

      Correct me if I’m wrong, but the script works faster with nested IFs since if it fails at the first one, it won’t bother reading next ones, unless you kill/return from function.

      All in all, this feels like readibility argument, not correctness or efficienty argument

  • M137
    link
    fedilink
    113 days ago

    Should be: if you play LoL at all you get banned.

  • @Dicska@lemmy.world
    link
    fedilink
    244 days ago

    It’s especially spicy when you consider that one single normal League match can easily extend beyond 30 minutes. Hell, even a lighter mode (ARAM) can be 30-35+ minutes at times.

  • NONE
    link
    fedilink
    34 days ago

    Is that GDScript (Godot Engine) or Python?

    • @felsiq@lemmy.zip
      link
      fedilink
      114 days ago

      It seems to match the discord bot api from python and that’d be a more logical choice for a bot lol

      • NONE
        link
        fedilink
        24 days ago

        That bot can recognize GDScript? Or can confuse it with Python? (Since both languages are very similar in some respects)

        • @felsiq@lemmy.zip
          link
          fedilink
          34 days ago

          Gonna state all my assumptions cuz I don’t think we’re talking about the same thing here:

          The bot I’m referring to is the discord bot that mod made, that monitors discord activities and bans discord users who play league for >30min. The code shown matches what I’d expect for that bot’s programming if python was used to create it, and doesn’t have anything to do with GDScript other than the mostly shared syntax between the two languages. I don’t think GDScript is likely outside a godot environment, and this bot is running on the discord side and not the game side.

          Sorry if this is still a shitty explanation of how I read the meme, brain isn’t braining right now lol

    • @OsrsNeedsF2P@lemmy.ml
      link
      fedilink
      8
      edit-2
      4 days ago

      GDScript is heavily inspired by Python’s syntax, but has a few differences with typing and string formatting. This code is Python but tbh would probably run on Godot

      Source: I code in Godot and Python