大佬教程收集整理的这篇文章主要介绍了更新 discord.py 机器人的 Cogs 以使用当前版本,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
因此,我正在尝试设计一个 older bot,旨在允许用户在 discord 客户端中玩 Blackjack 以熟悉 discord.py,但是当我在我的盒子。删除围绕添加齿轮的命令似乎足以让它工作,但这也有 / 轻微 / 完全破坏命令的轻微副作用。经过一些研究,我认为这与 discord.py API 自机器人首次创建(早在 2017 年)以来随着时间的推移而改变的方式有关,但作为 Python 的初学者 / 和 / 使用 discord.py ,我不知道为此找出具体的修复方法。
@H_419_3@import discord import asyncio from discord.ext import commands import configparser import bot_utilitIEs from blackjack import Blackjack config_file = 'bot_cfg.ini' record_file = 'player_records.Json' config = bot_utilitIEs.load_config(config_filE) bot = commands.bot( command_prefix=commands.when_mentioned,description=config.get('bot','description') ) @bot.event async def on_ready(): print('Logged in as') print(bot.user.Name) print(bot.user.ID) print('------') async def auto_update_records(fileName): """updates player records Json file every 3 hours""" await bot.wait_until_ready() while not bot.is_closed: await asyncio.sleep(10800.0) bot_utilitIEs.update_records(fileName) async def auto_give_points(): """Gives points every 24 hours.""" await bot.wait_until_ready() while not bot.is_closed: #Adjust point giving period as needed await asyncio.sleep(86400.0) bot_utilitIEs.give_points() update_task = bot.loop.create_task(auto_update_records(record_filE)) give_task = bot.loop.create_task(auto_give_points()) @bot.command(hIDden=True,pass_context=TruE) async def dc(ctX): """updates records before disconnecTing bot""" if ctx.message.author.ID == config.get('bot','admin'): bot_utilitIEs.update_records(record_filE) update_task.cancel() give_task.cancel() await bot.logout() print('disconnecTing bot...') bot_utilitIEs.load_records(bot,record_filE) bot.add_cog(Blackjack(bot)) try: bot.run(config.get('bot','token')) except: print('Login error or invalID token in bot config file.') exit() bot_utilitIEs.update_records(record_filE)
@H_419_3@bot.add_cog(Blackjack(bot)) 似乎是问题所在,但我也注意到它似乎是 bot.py 文件中唯一提到的 cogs(实际上,这是整个机器人项目中唯一提到的) ) 在定义命令本身之外。
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的更新 discord.py 机器人的 Cogs 以使用当前版本全部内容,希望文章能够帮你解决更新 discord.py 机器人的 Cogs 以使用当前版本所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。