#Does `test_guilds` accept empty lists?

1 messages · Page 1 of 1 (latest)

austere warren
#

If I pass an empty list to test_guilds for InteractionBot (well, just Bot tbh), is it still going to post the commands globally, or is it going to just not post at all because test_guilds has a value?

I can see that it accepts None as well but I wanted to know if there being an empty list being passed is the reason why none of my app commands have posted. (Though I'm still trying to see if it's still a case of waiting 1 hour until it posts the commands or not)

queen oyster
#

It would prevent them from syncing globally

austere warren
#

Looks like it doesn't, the code explicitly checks if test_guilds is None

austere warren
queen oyster
#
            guild_ids = cmd.guild_ids or test_guilds

            if guild_ids is None:
                global_cmds.append(cmd.body)
                continue

            for guild_id in guild_ids:
                if guild_id not in guilds:
                    guilds[guild_id] = [cmd.body]
                else:
                    guilds[guild_id].append(cmd.body)
#

If it's an empty list it gets converted to an empty tuple and iterated later, since there isn't any items there, it just doesn't register them

austere warren
#

Ah okay, that makes sense

#

Since it currently does None if test_guilds is None ..., could it not also just do None if not test_guilds or something like that?

queen oyster
#

Are you dynamically setting test_guilds for some reason?
Really not any reason to use it these days

austere warren
#

Yep

#

You're allowed to set test guilds (in a .env file) for testing the commands or whatever the case may be, but if you don't set the guilds then it'll know to just post them globally

queen oyster
#

Right.

austere warren
#

Though I can always make it return None if it doesn't find anything, just to simplify things, I just thought it would accept an empty list at first

queen oyster
#

Since global sync is nearly instant, it's not as useful

austere warren
#

Yeah that's fair

#

Thanks for the help

queen oyster
#

👍