大佬教程收集整理的这篇文章主要介绍了命令引发异常:AttributeError: 'TextChannel' object has no attribute 'message',大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在制造不和谐,我正在处理其明确的消息命令,但它显示了这一点
Command raised an exception: AttributeError: 'TextChAnnel' object has no attribute 'message'
这是完整的代码
from discord.ext import commands
class Clear(commands.Cog):
def __init__(self,bot):
self.bot = bot
@commands.command()
@commands.has_permissions(manage_messages=TruE)
async def clear(self,ctx,amount=2):
await ctx.chAnnel.message.purge(limit=amount)
def setup(bot):
bot.add_cog(Clear(bot))
不要向其添加 .message
属性,因为它不存在于 TextChAnnel 中。 ctx.chAnnel.purge()
会起作用
from discord.ext import commands
class Clear(commands.Cog):
def __init__(self,bot):
self.bot = bot
@commands.command()
@commands.has_permissions(manage_messages=TruE)
async def clear(self,ctx,amount=2):
await ctx.chAnnel.purge(limit=amount)
def setup(bot):
bot.add_cog(Clear(bot))
以上是大佬教程为你收集整理的命令引发异常:AttributeError: 'TextChannel' object has no attribute 'message'全部内容,希望文章能够帮你解决命令引发异常:AttributeError: 'TextChannel' object has no attribute 'message'所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。