Merge pull request #124 from irdumbs/patch-7

can add customcoms with (), ""
This commit is contained in:
Twentysix 2016-04-11 19:10:54 +02:00
commit 768c58e8a5

View File

@ -14,19 +14,13 @@ class CustomCommands:
@commands.command(pass_context=True, no_pm=True) @commands.command(pass_context=True, no_pm=True)
@checks.mod_or_permissions(manage_server=True) @checks.mod_or_permissions(manage_server=True)
async def addcom(self, ctx, command : str, *text): async def addcom(self, ctx, command : str, *, text):
"""Adds a custom command """Adds a custom command
Example: Example:
!addcom yourcommand Text you want !addcom yourcommand Text you want
""" """
if text == ():
await send_cmd_help(ctx)
return
server = ctx.message.server server = ctx.message.server
content = ctx.message.content
chars = (len(ctx.prefix), len(ctx.invoked_with), len(command))
text = content[chars[0] + chars[1] + chars[2] + 2:] # Gets text of the command
command = command.lower() command = command.lower()
if command in self.bot.commands.keys(): if command in self.bot.commands.keys():
await self.bot.say("That command is already a standard command.") await self.bot.say("That command is already a standard command.")
@ -44,19 +38,13 @@ class CustomCommands:
@commands.command(pass_context=True, no_pm=True) @commands.command(pass_context=True, no_pm=True)
@checks.mod_or_permissions(manage_server=True) @checks.mod_or_permissions(manage_server=True)
async def editcom(self, ctx, command : str, *text): async def editcom(self, ctx, command : str, *, text):
"""Edits a custom command """Edits a custom command
Example: Example:
!editcom yourcommand Text you want !editcom yourcommand Text you want
""" """
if text == ():
await send_cmd_help(ctx)
return
server = ctx.message.server server = ctx.message.server
content = ctx.message.content
chars = (len(ctx.prefix), len(ctx.invoked_with), len(command))
text = content[chars[0] + chars[1] + chars[2] + 2:] # Gets text of the command
command = command.lower() command = command.lower()
if server.id in self.c_commands: if server.id in self.c_commands:
cmdlist = self.c_commands[server.id] cmdlist = self.c_commands[server.id]
@ -156,4 +144,4 @@ def setup(bot):
check_files() check_files()
n = CustomCommands(bot) n = CustomCommands(bot)
bot.add_listener(n.checkCC, "on_message") bot.add_listener(n.checkCC, "on_message")
bot.add_cog(n) bot.add_cog(n)