如何在discord.py中更改前缀命令

如何在discord.py中更改前缀命令,discord.py,Discord.py,我想更改前缀命令。这是原始代码,但在你看之前,我已经到处找了,仍然找不到所有的东西 def get_prefix(bot, message): with open("prefixes.json", "r") as f: prefixes = json.load(f) return prefixes[str(message.guild.id)] bot = commands.Bot(command_prefix

我想更改前缀命令。这是原始代码,但在你看之前,我已经到处找了,仍然找不到所有的东西

def get_prefix(bot, message):

    with open("prefixes.json", "r") as f:
        prefixes = json.load(f)

    return prefixes[str(message.guild.id)]

    
bot = commands.Bot(command_prefix = get_prefix)








@bot.event
async def on_guild_join(guild):


    with open("prefixes.json", "r") as f:
        prefixes = json.load(f)

    prefixes[str(guild.id)] = "!"

    with open("prefixes.json", "w") as f:
        json.dump(prefixes,f)


@bot.command()
@commands.has_guild_permissions(administrator=True)
async def changeprefix(ctx, prefix):

    with open("prefixes.json", "r") as f:
        prefixes = json.load(f)

    prefixes[str(guild.id)] = prefix

    with open("prefixes.json", "w") as f:
        json.dump((prefixes,f))


@bot.event
async def on_message(msg):

    if msg.mentions[0] == bot.user:
        with open("prefixes.json", "r") as f:
         prefixes = json.load(f)

        pre = prefixes[str(msg.guild.id)]

        await msg.channel.send(f"My prefix for this server is {pre}")

    await bot.process_commands(msg)```


but then i kept on getting this error 
https://hastebin.com/bokezijece.rust

Can someone please help me i have looked at online tutorials and still cant get it to work and i even ask my freind that already has it but he wont help me because he is stubborn. I have asked every where and either non of the solutions work or they just straight up dont help me. and now stackoverflow is starting to anoy me as it is still saying my stuff is more code than detail aaaa.