[Core] Server based prefixes (#492)

Added `[p]set serverprefix`
`Bot.command_prefix` is now a callable that returns the prefixes set for the server. If none are set, it returns the global ones.
This commit is contained in:
Twentysix
2016-12-01 02:30:51 +01:00
committed by GitHub
parent 8b7ba988f4
commit d628bacef5
6 changed files with 127 additions and 62 deletions

View File

@@ -109,16 +109,15 @@ class CustomCommands:
if len(message.content) < 2 or message.channel.is_private:
return
msg = message.content
server = message.server
prefix = self.get_prefix(msg)
prefix = self.get_prefix(message)
if not prefix:
return
if server.id in self.c_commands and user_allowed(message):
cmdlist = self.c_commands[server.id]
cmd = msg[len(prefix):]
cmd = message.content[len(prefix):]
if cmd in cmdlist.keys():
cmd = cmdlist[cmd]
cmd = self.format_cc(cmd, message)
@@ -128,9 +127,9 @@ class CustomCommands:
cmd = self.format_cc(cmd, message)
await self.bot.send_message(message.channel, cmd)
def get_prefix(self, msg):
for p in self.bot.command_prefix:
if msg.startswith(p):
def get_prefix(self, message):
for p in self.bot.settings.get_prefixes(message.server):
if message.content.startswith(p):
return p
return False