ValueError:ind()中无效的文字,在Discord Bot中以10为底的错误

时间:2018-12-07 18:28:42

标签: python discord discord.py

我收到此错误:

    ValueError: invalid literal for int() with base 10: '<@256430125040533504>'

对于此代码:

     @client.command(pass_context=True)
async def give(self, user_id: discord.User.id, money: int):
    user_add_xp(user_id, money)
    embed = discord.Embed(description='{0} hat {1}EXP bekommen'.format(discord.User.name, money))
    await self.client.say(embed=embed)

此命令应向用户提供上述金额 该命令是或应该是 .give(名称)(金额)

1 个答案:

答案 0 :(得分:0)

在不了解其余代码结构的情况下,很难确切说明该命令的结构。以下是我的最佳猜测。

from discord.ext.commands import Bot
from discord import User

client = Bot(command_prefix='!')

@client.command(pass_context=True)
async def give(ctx, user: User, money: int):
    user_add_xp(user.id, money)
    embed = discord.Embed(description='{0} hat {1}EXP bekommen'.format(user.name, money))
    await client.say(embed=embed)

client.run("token")

请注意,我不使用self.client,因为此协程不是具有client属性的类的方法。相反,命令的第一个参数是调用上下文。