+ 1

[!answered!] There's an error with my code while I was coding discord bot, can anyone help?

import discord import os import discord client = discord.Client() @client.event async def on_ready(): print('We have logged in as {0.user}'.format(client)) @client.event async def on_message(message): if message.author == client.user: return if message.content.startswith('hello'): await message.channel.send('Hello!') #server list @bot.command(help = "Shows the Guild the bot is in") async def serverlist(ctx): if ctx.author.id == ownerID: msg = "\n".join(f"{x}" for x in bot.guilds) embed = Embed( title = "", description = "", color = col ) embed.add_field(name = "All Bots Guilds", value = f"```\n{msg}\n```") await ctx.send(embed = embed) client.run(os.getenv('TOKEN')) It says NameError: Name 'bot' is not defined

21st Feb 2022, 12:17 PM
Glitching shift Sans
Glitching shift Sans - avatar
2 Respostas
+ 1
bot = commands.Bot( command_prefix="!", # Change to desired prefix case_insensitive=True # Commands aren't case-sensitive )
21st Feb 2022, 1:21 PM
Glitching shift Sans
Glitching shift Sans - avatar
0
For the location where it is It's at line 24 @bot.command(help = "shows the guild the bot is in")
21st Feb 2022, 12:18 PM
Glitching shift Sans
Glitching shift Sans - avatar