1
0
Fork 0
mirror of synced 2024-09-28 23:41:41 +12:00

Added an error checking in case a tag was provided in the incorrect format

This commit is contained in:
Phxntxm 2016-08-04 10:47:34 -05:00
parent c907f76ac8
commit 567162268b

View file

@ -34,11 +34,16 @@ class Tags:
async def add_tag(self, ctx, *, result: str): async def add_tag(self, ctx, *, result: str):
"""Use this to add a new tag that can be used in this server """Use this to add a new tag that can be used in this server
Format to add a tag is !tag add <tag> - <result>""" Format to add a tag is !tag add <tag> - <result>"""
tag = result[0:result.find('-')].strip() try:
tag_result = result[result.find('-') + 2:].strip() tag = re.search("(.*) - (.*)",result).group(1).strip()
if len(tag) == 0 or len(result) == 0: tag_result = "(.*) - (.*)",result).group(2).strip()
except AttributeError:
await self.bot.say("Please provide the format for the tag in: !tag add <tag> - <result>") await self.bot.say("Please provide the format for the tag in: !tag add <tag> - <result>")
return return
if len(tag) == 0 or len(tag_result) == 0:
await self.bot.say("Please provide the format for the tag in: !tag add <tag> - <result>")
return
tags = config.getContent('tags') tags = config.getContent('tags')
for t in tags: for t in tags:
if t['tag'] == tag and t['server_id'] == ctx.message.server.id: if t['tag'] == tag and t['server_id'] == ctx.message.server.id: