mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-08 18:32:32 -05:00
[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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user