Answer the question
In order to leave comments, you need to log in
Error in code, why?
I am writing a bot, and I can’t fix it, help, here is the code and the error itself:
channel_chat = client.get_channel(879035346015359023)
message = await channel_chat.send(embed = discord.Embed(title="Внимание! Идёт установка ролей..", description="Ожидайте...", colour=discord.Colour.from_rgb(255, 0, 0)))
getrole = discord.utils.get(ctx.guild.roles, id=879035345969217558)
guild = ctx.guild
for member in guild:
if role not in member.roles:
await member.add_roles(getrole)
await message.edit(embed = discord.Embed(title="Установка завершилась!",description=f"Ролей выдано :: {ctx.guild.member_count}", colour=discord.Colour.from_rgb(0, 255, 0)))
await message.add_reaction("✅")
return
return
Answer the question
In order to leave comments, you need to log in
As already mentioned in the comments - you are trying to iterate the guild object itself, not its members.
for member in ctx.guild.members: # зачем делать переменную, которая будет использоваться один раз?
if role not in member.roles:
await member.add_roles(getrole)
await message.edit(embed = discord.Embed(title="Установка завершилась!",description=f"Ролей выдано :: {ctx.guild.member_count}", colour=discord.Colour.from_rgb(0, 255, 0)))
await message.add_reaction("✅")
return
I heard that discord.py does not work in 3.9 version of python, try using (3.8) in another version of the intopritor. and if this version is not 3.9, then I don’t know.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question