This is my code:
@client.event
async def on_ready():
print('CONSOLE: We have logged in as {0.user}'.format(client))
async def serverList():
for guild in client.guilds:
print(guild.id)
client.run(token)
I am trying to list the guild/servers the bot is in but this code does not work
CodePudding user response:
In order to get your code to work you need to delete the line async def serverList():
and correct indents so the for
loop is on the same level with the very first print('CONSOLE...
@client.event
async def on_ready():
print('CONSOLE: We have logged in as {0.user}'.format(client))
for guild in client.guilds:
print(guild.id)
client.run(token)
Code does not run probably because of wrong indents - you have an extra unnecessary indent in your async def serverList()
,
or if the problem that guild.id
s do not get printed then is happening because you define the function with async def
but you don't end up using it in your code.