I created this Economy category for my bot which currently has 2 commands. Balance and Transfer. I am trying to add a work command and I came up with this:
@commands.command()
async def work(self, ctx):
id = str(ctx.message.author.id)
amount = {random.choice(x)}
amounts[id] += amount
await ctx.send(f"You worked at a dumpster and earned {random.choice(x)}")
but PyCharm came up with this error:
Ignoring exception in command work:
Traceback (most recent call last):
File "C:UsersMainAccountPycharmProjectsCat_Botvenvlibsite-packagesdiscordextcommandscore.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:UsersMainAccountPycharmProjectsCat_Botcogscog_economy.py", line 85, in work
amounts[id] += amount
TypeError: unsupported operand type(s) for +=: 'int' and 'set'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:UsersMainAccountPycharmProjectsCat_Botvenvlibsite-packagesdiscordextcommandsot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "C:UsersMainAccountPycharmProjectsCat_Botvenvlibsite-packagesdiscordextcommandscore.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:UsersMainAccountPycharmProjectsCat_Botvenvlibsite-packagesdiscordextcommandscore.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: unsupported operand type(s) for +=: 'int' and 'set'
Could someone help me to fix this? And please explain the problem if you have the answer
question from:
https://stackoverflow.com/questions/65868309/how-do-i-make-a-work-command-pycharm-2020-3-2-python-3-9 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…