I dont get whats wrong with this.. how could i fix it?
for users in ctx.guild.members:
winner = random.choice(users)
await channel.send(f"Congratulations! {winner} won {prize}!")
Traceback:
AttributeError: 'NoneType' object has no attribute 'id'
Ignoring exception in command giveaway:
Traceback (most recent call last):
File "C:\Users\Zsombor\Desktop\Dexton\Cogs\giveaway.py", line 115, in giveaway
winner = random.choice(users)
TypeError: object of type 'Member' has no len()
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: object of type 'Member' has no len()
>Solution :
The random.choice() takes a random item out of a list. So if you execute it on a single object, you get that error. In your case, a for loop is not necessary, just do
winner = random.choice(ctx.guild.members)