Discord.py List all server names where the bot is in
Question:
I made a bot but I want the bot to make list all the server names where it is when you type a command.
Can any one help me, please?
Answers:
await ctx.send('n'.join(guild.name for guild in bot.guilds))
Just remember to pass an intent with guilds enabled in your bot’s constructor
@commands.command()
async def servers(self, ctx):
activeservers = client.guilds
for guild in activeservers:
await ctx.send(guild.name)
print(guild.name)
This code should work
@client.command()
async def server(ctx):
servers = list(client.guilds)
for server in servers:
await ctx.send(server.name)
it works for me…
I made a bot but I want the bot to make list all the server names where it is when you type a command.
Can any one help me, please?
await ctx.send('n'.join(guild.name for guild in bot.guilds))
Just remember to pass an intent with guilds enabled in your bot’s constructor
@commands.command()
async def servers(self, ctx):
activeservers = client.guilds
for guild in activeservers:
await ctx.send(guild.name)
print(guild.name)
This code should work
@client.command()
async def server(ctx):
servers = list(client.guilds)
for server in servers:
await ctx.send(server.name)
it works for me…