下面是我的Discord机器人的代码
def dice(bot,update):
bot.send_dice.message(chat_id = update.message.chat_id)
updater = Updater(API_KEY,use_context=True)
dp = updater.dispatcher
dp.add_handler(CommandHandler('dice',dice))
此代码产生以下错误:
AttributeError: 'Update' object has no attribute 'send_dice'
请帮忙,我不知道这是怎么回事
该错误可能是由于您使用的是旧式签名
def callback(bot, update)
,而在python-telegram
上使用的是版本为>=12新语法是def callback(update, context)
,其中context
是一个对象,包含bot实例作为context.bot
以及一系列其他实用程序功能有关详细信息,请参阅transition guide to version 12(以及version 13,如果适用的话)
免责声明:我是
python-telegram-bot
的维护者相关问题 更多 >
编程相关推荐