| Total Complexity | 8 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import discord |
||
| 2 | from discord.ext import commands |
||
| 3 | from discord_slash.model import SlashCommandPermissionType |
||
| 4 | from discord_slash.utils.manage_commands import create_permission |
||
| 5 | from modules.get_settings import get_settings |
||
| 6 | |||
| 7 | GUILD_IDS = get_settings("guild") |
||
| 8 | MODERATION_IDS = get_settings("MOD_ROLES") |
||
| 9 | PERMISSION_MODS = { |
||
| 10 | GUILD_IDS[0]: [ |
||
| 11 | create_permission(MODERATION_IDS[0], SlashCommandPermissionType.ROLE, True), |
||
| 12 | create_permission(MODERATION_IDS[1], SlashCommandPermissionType.ROLE, True) |
||
| 13 | ] |
||
| 14 | } |
||
| 15 | PERMISSION_ADMINS = { |
||
| 16 | GUILD_IDS[0]: [ |
||
| 17 | create_permission(get_settings("ADMIN"), SlashCommandPermissionType.USER, True) |
||
| 18 | ] |
||
| 19 | } |
||
| 20 | |||
| 21 | |||
| 22 | # noinspection PyTypeChecker |
||
| 23 | class BaseCog(commands.Cog): |
||
| 24 | def __init__(self, bot): |
||
| 25 | self.bot = bot |
||
| 26 | print(f"[{self.__class__.__name__}]: Init") |
||
| 27 | |||
| 28 | def get_bot(self): |
||
| 29 | return self.bot |
||
| 30 | |||
| 31 | # Find monster in config |
||
| 32 | def get_monster(self, ctx, name: str): |
||
| 33 | name = name.lower() |
||
| 34 | monster_found = [] |
||
| 35 | |||
| 36 | for monster in self.bot.config["commands"]: |
||
| 37 | if monster["name"].lower() == name or name in monster["triggers"]: |
||
| 38 | monster_found = monster |
||
| 39 | |||
| 40 | if not monster_found: |
||
| 41 | print(f"[{self.__class__.__name__}]: Monster not found ({ctx.author}: {name})") |
||
| 42 | return |
||
| 43 | |||
| 44 | monster_found["role"] = discord.utils.get(ctx.guild.roles, name=monster_found["name"]) |
||
| 45 | if not monster_found["role"]: |
||
| 46 | print(f"[{self.__class__.__name__}]: Failed to fetch roleID for monster {monster_found['name']}") |
||
| 47 | return |
||
| 48 | |||
| 49 | else: |
||
| 50 | monster_found["role"] = monster_found["role"].id |
||
| 51 | return monster_found |
||
| 52 |