我无法使用漫游器命令,并且TypeError:“属性”对象不可调用

时间:2019-12-27 14:37:51

标签: python python-3.x discord.py

我用Python制作了不和谐的机器人。 但是我什至打开了电源,无法使用任何机器人命令,并且发生了错误(TypeError:“ property”对象不可调用) 我该怎么办?

manage.py

import discord
import asyncio
import re
import json
from discord.ext import commands
from discord import Permissions as permissions

class manage(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.command()
    @commands.guild_only()
    @permissions.administrator()
    async def prefix(self, ctx, *, prefixes=""):
        try:
            with open('config/setting.json') as json_file:
                json_data = json.load(json_file)
                prefix = json_data["prefix"]
        except:
            await ctx.send("An error occured.(Bot has an error.)")
        if(prefixes != ""):
            try:
                custom_prefixes = prefixes
                custom_prefixes[ctx.guild.id] = prefixes.split() or prefix
                await ctx.send("Changed prefix. Now new prefix is **{}**.".format(custom_prefixes))
            except:
                await ctx.send("An error occured.(Check your command or bot has an error.)")
def setup(bot):
    bot.add_cog(manage(bot))

如果您需要其他代码,请链接:github

1 个答案:

答案 0 :(得分:0)

@permissions.administrator()

不正确。相反,您应该使用commands.has_permissions支票

@commands.command()
@commands.guild_only()
@commands.has_permissions(administrator=True)
async def prefix(self, ctx, *, prefixes=""):