I am coding a bot to find users with the 'Admin' role on my discord server and do something with them. So far I have written this:
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix="$")
role_name = "Admin"
peopleWithRole = []
@bot.event
async def on_ready():
print("Logged in as")
print(bot.user.name)
print("------")
role = discord.utils.find(
lambda r: r.name == role_name, guild.roles)
for user in guild.members:
if role in user.roles:
peopleWithRole.append(user)
bot.run("My token")
However, when I run this, I get an error saying that name 'guild' is not defined. I am just starting out with discord.py and I was also wondering whether I should be using client or bot in this situation.