| Conditions | 6 |
| Total Lines | 29 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import discord |
||
| 32 | def get_monster(self, ctx, name: str): |
||
| 33 | """ |
||
| 34 | |||
| 35 | :param ctx: |
||
| 36 | :type ctx: |
||
| 37 | :param name: |
||
| 38 | :type name: |
||
| 39 | :return: |
||
| 40 | :rtype: |
||
| 41 | """ |
||
| 42 | monster_found = [] |
||
| 43 | name = name.lower() |
||
| 44 | |||
| 45 | for monster in self.bot.config["commands"]: |
||
| 46 | if monster["name"].lower() == name or name in monster["triggers"]: |
||
| 47 | monster_found = monster |
||
| 48 | |||
| 49 | if not monster_found: |
||
| 50 | print(f"[{self.__class__.__name__}]: Monster not found") |
||
| 51 | return |
||
| 52 | |||
| 53 | monster_found["role"] = discord.utils.get(ctx.guild.roles, name=monster_found["name"]) |
||
| 54 | if not monster_found["role"]: |
||
| 55 | print(f"[{self.__class__.__name__}]: Failed to fetch roleID for monster {monster_found['name']}") |
||
| 56 | return |
||
| 57 | |||
| 58 | else: |
||
| 59 | monster_found["role"] = monster_found["role"].id |
||
| 60 | return monster_found |
||
| 61 |