#server.leave()

1 messages · Page 1 of 1 (latest)

fleet narwhal
#

read below

#
@client.command()
@commands.guild_only()
async def leave(ctx, guild1):
  if ctx.author.id == 993619868710617108: 
    server = client.get_guild(guild1)
    try:
      await server.leave()
      await ctx.send(":thumbsup:")
      print(f"left {ctx.guild.name} | {ctx.guild.id}")
    except Exception as e:
      await ctx.send(":thumbsdown:")
      print(e)
  else:
    return```
#

getting the error 'NoneType' object has no attribute 'leave' and i have no idea why tbh

bleak geyser
#

maybe try
server = client.get_guild(int(guild1))

fleet narwhal
heavy flower
fleet narwhal
fleet narwhal
bleak geyser
#

do you have guilds intent enabled?

fleet narwhal
gentle musk
#

your code is fine (assuming you do int(guild1)), but it's returning None because the bot isn't in that guild or the guild ID is wrong

heavy flower
heavy flower