python - @commands.has permissions(administrator=true) 命令没有属性 has_permisions 错误
问题描述
我正在编写一个机器人,这里是整个代码:
print("Loading bot...")
import discord
import time
import asyncio
import datetime
import requests
from discord.ext import commands
from discord.ext import tasks
from discord.utils import get
from webserver import keep_alive
import os
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="t.", intents=intents)
bot.remove_command('help')
[Other code]
#Purge command
@bot.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def purge(ctx, limit: int):
await ctx.channel.purge(limit=limit)
await ctx.send("Messages purged ")
await ctx.message.delete()
keep_alive()
bot.run('TOKEN)
我的错误: 点击这里
是的,我在 python 3.8.5 上使用 replit 有什么问题?希望你能回答我的问题。我真的不知道该怎么办,discord.py 是一种很奇怪的编程语言:/ 谢谢 Evo
解决方案
将其导入您的文件中,from discord.ext.commands import has_permissions, MissingPermissions
这可能会对您有所帮助并使该行@has_permissions(administrator=True)
推荐阅读
- assembly - 如何强制汇编器使用特定编码发出代码?
- macos - Jupyterhub 不通过 plist 运行
- android - 如何在 android 通知面板中为我们自己的应用程序(如 paytm)实现快速启动选项?
- tfs - 无法撤消,因为“此处的 tfs 文件路径”中已存在文件。必须从磁盘中删除文件才能成功撤消
- xcode - Xcode Export for Localization 卡住了
- spring - 使用 JPA 保存数据的 Junit 测试
- wordpress - Wordpress 单页产品和结帐
- azure - 如何获取事件中心 Azure 的不记名令牌
- objective-c - 如何在 iOS 的通知中创建 ProgressBar?
- kubernetes - Pod 完成但没有完成过程