• Sjmarf@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      3
      ·
      14 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')
      
    • Jankatarch@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      14 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.

        • underscores@lemmy.zip
          link
          fedilink
          English
          arrow-up
          1
          ·
          edit-2
          13 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

        • kernelle@0d.gs
          link
          fedilink
          arrow-up
          1
          ·
          13 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.

    • REDACTED@infosec.pub
      link
      fedilink
      English
      arrow-up
      0
      arrow-down
      6
      ·
      13 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

  • Pnut@lemm.ee
    link
    fedilink
    arrow-up
    1
    ·
    14 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.

    • Alteon@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      13 days ago

      I tried playing it while unemployed. Did not click with me. At all. I just don’t get it.

      • Kogasa@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        12 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
      arrow-up
      1
      ·
      14 days ago

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