Per server prefixs

后端 未结 2 912
攒了一身酷
攒了一身酷 2021-01-02 20:47

I was wondering how I would go about allowing every server my bot is connected to, to set their own prefix. I am using the async version of dpy with Commands ext. I would a

2条回答
  •  一生所求
    2021-01-02 21:12

    Late answer, but for those others also looking for this you can use the get_prefix function.

    It's very similar to Patrick Haugh's version, but a little different maybe because of different discord library versions?

    prefixes = ['.','!','s.','k!']
    ser_pref={'server id':['.',',']}
    def get_prefix(bot, msg):
        if msg.guild.id in ser_pref:
            return commands.when_mentioned_or(*ser_pref['server id'])
    
    
        return commands.when_mentioned_or(*prefixes)(bot, msg)
    
    bot = commands.Bot(command_prefix=get_prefix)
    

    You can then later make commands to allow more custom server prefixes to other servers by adding their options to the dict

提交回复
热议问题