#server.leave()
1 messages · Page 1 of 1 (latest)
@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
maybe try
server = client.get_guild(int(guild1))
nope same error
For some reason, discord doesn't recognize IDs as valid integers, so I did a similar command with a modal and it worked
can you send the code so i can look at it?
cuz ive used similar code to this in my bot in another command and it worked so im super confused
do you have guilds intent enabled?
yh
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
I suggested this because when I attempt to pass in a guild id in my slash command arguments, it shows "invalid integer" and doesn't let me invoke it
If you need help figuring out how to code a modal, pycord website has guides on it and there are tutos on yt