Reputation: 43
So I'm trying to make it so that a moderator could register a user onto a JSON file, where we store currency.
This is my code, I'm getting the error :
id = str(ctx.message.member.id)
AttributeError: 'Message' object has no attribute 'member'
@bot.command(pass_context=True)
async def registeruser(ctx, member: discord.Member):
id = str(ctx.message.member.id)
if id not in amounts:
amounts[id] = 0
await ctx.send("You are now registered to AccoladeBot.")
_save()
else:
await ctx.send("You already have an account.")```
Upvotes: 0
Views: 1620
Reputation: 3994
If you want to check if the specified user has an account or not, you should write str(member.id)
instead of str(ctx.message.member.id)
@bot.command()
async def registeruser(ctx, member: discord.Member):
id = str(member.id)
if id not in amounts:
amounts[id] = 0
await ctx.send("You are now registered to AccoladeBot.")
_save()
else:
await ctx.send("You already have an account.")
More about the Context
object here.
Upvotes: 1