Improved feature flag for server handling #334
This commit is contained in:
parent
1b2bb85b37
commit
5dd2000f10
@ -1 +1 @@
|
|||||||
Subproject commit 359f9c38c3ec825a89f3bf289a65ec035cfcb693
|
Subproject commit 5e8e5caf886cf99dd74339bd7cdceb2f6c0ecb88
|
@ -51,6 +51,9 @@ class AchievementGroup(DiscordCommandABC):
|
|||||||
@CommandChecks.check_is_member_moderator()
|
@CommandChecks.check_is_member_moderator()
|
||||||
async def check(self, ctx: Context, member: discord.Member):
|
async def check(self, ctx: Context, member: discord.Member):
|
||||||
self._logger.debug(__name__, f"Received command achievement check {ctx}")
|
self._logger.debug(__name__, f"Received command achievement check {ctx}")
|
||||||
|
if ctx.guild is None:
|
||||||
|
return
|
||||||
|
|
||||||
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}")
|
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}")
|
||||||
if not FeatureFlagsSettings.get_flag_from_dict(
|
if not FeatureFlagsSettings.get_flag_from_dict(
|
||||||
server_config.feature_flags, FeatureFlagsEnum.achievements_module
|
server_config.feature_flags, FeatureFlagsEnum.achievements_module
|
||||||
|
@ -37,15 +37,18 @@ class AchievementOnMessageEvent(OnMessageABC):
|
|||||||
|
|
||||||
@EventChecks.check_is_ready()
|
@EventChecks.check_is_ready()
|
||||||
async def on_message(self, message: discord.Message):
|
async def on_message(self, message: discord.Message):
|
||||||
|
if message.guild is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
if message.author.bot:
|
||||||
|
return
|
||||||
|
|
||||||
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{message.guild.id}")
|
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{message.guild.id}")
|
||||||
if not FeatureFlagsSettings.get_flag_from_dict(
|
if not FeatureFlagsSettings.get_flag_from_dict(
|
||||||
server_config.feature_flags, FeatureFlagsEnum.achievements_module
|
server_config.feature_flags, FeatureFlagsEnum.achievements_module
|
||||||
):
|
):
|
||||||
return
|
return
|
||||||
|
|
||||||
if message.author.bot:
|
|
||||||
return
|
|
||||||
|
|
||||||
server = self._servers.get_server_by_discord_id(message.guild.id)
|
server = self._servers.get_server_by_discord_id(message.guild.id)
|
||||||
user = self._users.get_user_by_discord_id_and_server_id(message.author.id, server.id)
|
user = self._users.get_user_by_discord_id_and_server_id(message.author.id, server.id)
|
||||||
|
|
||||||
|
@ -75,11 +75,11 @@ class AutoRoleGroup(DiscordCommandABC):
|
|||||||
@CommandChecks.check_is_member_moderator()
|
@CommandChecks.check_is_member_moderator()
|
||||||
async def list(self, ctx: Context, wait: int = None):
|
async def list(self, ctx: Context, wait: int = None):
|
||||||
self._logger.debug(__name__, f"Received command auto-role list {ctx}")
|
self._logger.debug(__name__, f"Received command auto-role list {ctx}")
|
||||||
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild_id}")
|
if ctx.guild is None:
|
||||||
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module):
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if ctx.guild is None:
|
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild_id}")
|
||||||
|
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module):
|
||||||
return
|
return
|
||||||
|
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
@ -119,6 +119,9 @@ class AutoRoleGroup(DiscordCommandABC):
|
|||||||
@CommandChecks.check_is_member_moderator()
|
@CommandChecks.check_is_member_moderator()
|
||||||
async def add(self, ctx: Context, channel: discord.TextChannel, message_id: str):
|
async def add(self, ctx: Context, channel: discord.TextChannel, message_id: str):
|
||||||
self._logger.debug(__name__, f"Received command auto-role add {ctx} {message_id}")
|
self._logger.debug(__name__, f"Received command auto-role add {ctx} {message_id}")
|
||||||
|
if ctx.guild is None:
|
||||||
|
return
|
||||||
|
|
||||||
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild_id}")
|
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild_id}")
|
||||||
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module):
|
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module):
|
||||||
return
|
return
|
||||||
@ -182,6 +185,9 @@ class AutoRoleGroup(DiscordCommandABC):
|
|||||||
@CommandChecks.check_is_member_moderator()
|
@CommandChecks.check_is_member_moderator()
|
||||||
async def remove(self, ctx: Context, auto_role: int):
|
async def remove(self, ctx: Context, auto_role: int):
|
||||||
self._logger.debug(__name__, f"Received command auto-role remove {ctx} {auto_role}")
|
self._logger.debug(__name__, f"Received command auto-role remove {ctx} {auto_role}")
|
||||||
|
if ctx.guild is None:
|
||||||
|
return
|
||||||
|
|
||||||
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild_id}")
|
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild_id}")
|
||||||
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module):
|
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module):
|
||||||
return
|
return
|
||||||
@ -225,6 +231,9 @@ class AutoRoleGroup(DiscordCommandABC):
|
|||||||
@CommandChecks.check_is_member_moderator()
|
@CommandChecks.check_is_member_moderator()
|
||||||
async def list(self, ctx: Context, auto_role: int, wait: int = None):
|
async def list(self, ctx: Context, auto_role: int, wait: int = None):
|
||||||
self._logger.debug(__name__, f"Received command auto-role rule list {ctx}")
|
self._logger.debug(__name__, f"Received command auto-role rule list {ctx}")
|
||||||
|
if ctx.guild is None:
|
||||||
|
return
|
||||||
|
|
||||||
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild_id}")
|
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild_id}")
|
||||||
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module):
|
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module):
|
||||||
return
|
return
|
||||||
@ -280,6 +289,9 @@ class AutoRoleGroup(DiscordCommandABC):
|
|||||||
@CommandChecks.check_is_member_moderator()
|
@CommandChecks.check_is_member_moderator()
|
||||||
async def add(self, ctx: Context, auto_role: int, emoji_name: str, role_id: str):
|
async def add(self, ctx: Context, auto_role: int, emoji_name: str, role_id: str):
|
||||||
self._logger.debug(__name__, f"Received command auto-role add {ctx} {auto_role}")
|
self._logger.debug(__name__, f"Received command auto-role add {ctx} {auto_role}")
|
||||||
|
if ctx.guild is None:
|
||||||
|
return
|
||||||
|
|
||||||
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild_id}")
|
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild_id}")
|
||||||
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module):
|
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module):
|
||||||
return
|
return
|
||||||
@ -375,6 +387,9 @@ class AutoRoleGroup(DiscordCommandABC):
|
|||||||
@CommandChecks.check_is_member_moderator()
|
@CommandChecks.check_is_member_moderator()
|
||||||
async def remove(self, ctx: Context, auto_role_rule: int):
|
async def remove(self, ctx: Context, auto_role_rule: int):
|
||||||
self._logger.debug(__name__, f"Received command auto-role remove {ctx} {auto_role_rule}")
|
self._logger.debug(__name__, f"Received command auto-role remove {ctx} {auto_role_rule}")
|
||||||
|
if ctx.guild is None:
|
||||||
|
return
|
||||||
|
|
||||||
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild_id}")
|
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild_id}")
|
||||||
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module):
|
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module):
|
||||||
return
|
return
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
from cpl_core.configuration import ConfigurationABC
|
||||||
from cpl_core.database.context import DatabaseContextABC
|
from cpl_core.database.context import DatabaseContextABC
|
||||||
from cpl_core.time import TimeFormatSettings
|
from cpl_core.time import TimeFormatSettings
|
||||||
from cpl_discord.events import OnCommandABC
|
from cpl_discord.events import OnCommandABC
|
||||||
@ -13,12 +14,14 @@ from bot_core.logging.command_logger import CommandLogger
|
|||||||
from bot_data.abc.client_repository_abc import ClientRepositoryABC
|
from bot_data.abc.client_repository_abc import ClientRepositoryABC
|
||||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||||
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||||
|
from bot_data.model.server_config import ServerConfig
|
||||||
from bot_data.model.user import User
|
from bot_data.model.user import User
|
||||||
|
|
||||||
|
|
||||||
class BaseOnCommandEvent(OnCommandABC):
|
class BaseOnCommandEvent(OnCommandABC):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
config: ConfigurationABC,
|
||||||
logger: CommandLogger,
|
logger: CommandLogger,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
messenger: MessageServiceABC,
|
messenger: MessageServiceABC,
|
||||||
@ -30,6 +33,7 @@ class BaseOnCommandEvent(OnCommandABC):
|
|||||||
servers: ServerRepositoryABC,
|
servers: ServerRepositoryABC,
|
||||||
):
|
):
|
||||||
OnCommandABC.__init__(self)
|
OnCommandABC.__init__(self)
|
||||||
|
self._config = config
|
||||||
self._logger = logger
|
self._logger = logger
|
||||||
self._bot = bot
|
self._bot = bot
|
||||||
self._messenger = messenger
|
self._messenger = messenger
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
from cpl_core.configuration import ConfigurationABC
|
||||||
from cpl_core.database.context import DatabaseContextABC
|
from cpl_core.database.context import DatabaseContextABC
|
||||||
from cpl_discord.events import OnMessageDeleteABC
|
from cpl_discord.events import OnMessageDeleteABC
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
@ -10,12 +11,14 @@ from bot_core.logging.message_logger import MessageLogger
|
|||||||
from bot_data.abc.client_repository_abc import ClientRepositoryABC
|
from bot_data.abc.client_repository_abc import ClientRepositoryABC
|
||||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||||
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||||
|
from bot_data.model.server_config import ServerConfig
|
||||||
from bot_data.model.user import User
|
from bot_data.model.user import User
|
||||||
|
|
||||||
|
|
||||||
class BaseOnMessageDeleteEvent(OnMessageDeleteABC):
|
class BaseOnMessageDeleteEvent(OnMessageDeleteABC):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
config: ConfigurationABC,
|
||||||
logger: MessageLogger,
|
logger: MessageLogger,
|
||||||
db: DatabaseContextABC,
|
db: DatabaseContextABC,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
@ -24,6 +27,7 @@ class BaseOnMessageDeleteEvent(OnMessageDeleteABC):
|
|||||||
servers: ServerRepositoryABC,
|
servers: ServerRepositoryABC,
|
||||||
):
|
):
|
||||||
OnMessageDeleteABC.__init__(self)
|
OnMessageDeleteABC.__init__(self)
|
||||||
|
self._config = config
|
||||||
self._logger = logger
|
self._logger = logger
|
||||||
self._db = db
|
self._db = db
|
||||||
self._bot = bot
|
self._bot = bot
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from typing import List as TList
|
from typing import List as TList
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
from cpl_core.configuration import ConfigurationABC
|
||||||
from cpl_core.database.context import DatabaseContextABC
|
from cpl_core.database.context import DatabaseContextABC
|
||||||
from cpl_discord.command import DiscordCommandABC
|
from cpl_discord.command import DiscordCommandABC
|
||||||
from cpl_discord.container import Guild, Role
|
from cpl_discord.container import Guild, Role
|
||||||
@ -12,12 +13,15 @@ from discord.ext.commands import Context
|
|||||||
|
|
||||||
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
||||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||||
|
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||||
|
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
||||||
from bot_core.helper.command_checks import CommandChecks
|
from bot_core.helper.command_checks import CommandChecks
|
||||||
from bot_core.logging.command_logger import CommandLogger
|
from bot_core.logging.command_logger import CommandLogger
|
||||||
from bot_data.abc.level_repository_abc import LevelRepositoryABC
|
from bot_data.abc.level_repository_abc import LevelRepositoryABC
|
||||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||||
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||||
from bot_data.model.level import Level
|
from bot_data.model.level import Level
|
||||||
|
from bot_data.model.server_config import ServerConfig
|
||||||
from modules.level.level_seeder import LevelSeeder
|
from modules.level.level_seeder import LevelSeeder
|
||||||
from modules.level.service.level_service import LevelService
|
from modules.level.service.level_service import LevelService
|
||||||
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
||||||
@ -26,6 +30,7 @@ from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
|||||||
class LevelGroup(DiscordCommandABC):
|
class LevelGroup(DiscordCommandABC):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
config: ConfigurationABC,
|
||||||
logger: CommandLogger,
|
logger: CommandLogger,
|
||||||
message_service: MessageServiceABC,
|
message_service: MessageServiceABC,
|
||||||
bot: DiscordBotServiceABC,
|
bot: DiscordBotServiceABC,
|
||||||
@ -41,6 +46,7 @@ class LevelGroup(DiscordCommandABC):
|
|||||||
):
|
):
|
||||||
DiscordCommandABC.__init__(self)
|
DiscordCommandABC.__init__(self)
|
||||||
|
|
||||||
|
self._config = config
|
||||||
self._logger = logger
|
self._logger = logger
|
||||||
self._message_service = message_service
|
self._message_service = message_service
|
||||||
self._bot = bot
|
self._bot = bot
|
||||||
@ -125,10 +131,13 @@ class LevelGroup(DiscordCommandABC):
|
|||||||
@CommandChecks.check_is_member_moderator()
|
@CommandChecks.check_is_member_moderator()
|
||||||
async def list(self, ctx: Context, wait: int = None):
|
async def list(self, ctx: Context, wait: int = None):
|
||||||
self._logger.debug(__name__, f"Received command level list {ctx}")
|
self._logger.debug(__name__, f"Received command level list {ctx}")
|
||||||
|
|
||||||
if ctx.guild is None:
|
if ctx.guild is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}")
|
||||||
|
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module):
|
||||||
|
return
|
||||||
|
|
||||||
server = self._servers.get_server_by_discord_id(ctx.guild.id)
|
server = self._servers.get_server_by_discord_id(ctx.guild.id)
|
||||||
levels = self._levels.get_levels_by_server_id(server.id)
|
levels = self._levels.get_levels_by_server_id(server.id)
|
||||||
if levels.count() < 1:
|
if levels.count() < 1:
|
||||||
@ -169,6 +178,12 @@ class LevelGroup(DiscordCommandABC):
|
|||||||
@CommandChecks.check_is_member_admin()
|
@CommandChecks.check_is_member_admin()
|
||||||
async def create(self, ctx: Context, name: str, color: str, min_xp: int, permissions: int):
|
async def create(self, ctx: Context, name: str, color: str, min_xp: int, permissions: int):
|
||||||
self._logger.debug(__name__, f"Received command level create {ctx}")
|
self._logger.debug(__name__, f"Received command level create {ctx}")
|
||||||
|
if ctx.guild is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}")
|
||||||
|
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module):
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
color = hex(discord.Colour.from_str(color).value)
|
color = hex(discord.Colour.from_str(color).value)
|
||||||
@ -258,6 +273,12 @@ class LevelGroup(DiscordCommandABC):
|
|||||||
permissions: int = None,
|
permissions: int = None,
|
||||||
):
|
):
|
||||||
self._logger.debug(__name__, f"Received command level edit {ctx}")
|
self._logger.debug(__name__, f"Received command level edit {ctx}")
|
||||||
|
if ctx.guild is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}")
|
||||||
|
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module):
|
||||||
|
return
|
||||||
|
|
||||||
server = self._servers.get_server_by_discord_id(ctx.guild.id)
|
server = self._servers.get_server_by_discord_id(ctx.guild.id)
|
||||||
level_from_db = (
|
level_from_db = (
|
||||||
@ -350,6 +371,12 @@ class LevelGroup(DiscordCommandABC):
|
|||||||
@CommandChecks.check_is_member_admin()
|
@CommandChecks.check_is_member_admin()
|
||||||
async def remove(self, ctx: Context, level: str):
|
async def remove(self, ctx: Context, level: str):
|
||||||
self._logger.debug(__name__, f"Received command level remove {ctx}")
|
self._logger.debug(__name__, f"Received command level remove {ctx}")
|
||||||
|
if ctx.guild is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}")
|
||||||
|
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module):
|
||||||
|
return
|
||||||
|
|
||||||
server = self._servers.get_server_by_discord_id(ctx.guild.id)
|
server = self._servers.get_server_by_discord_id(ctx.guild.id)
|
||||||
level_from_db = (
|
level_from_db = (
|
||||||
@ -394,6 +421,12 @@ class LevelGroup(DiscordCommandABC):
|
|||||||
@CommandChecks.check_is_member_moderator()
|
@CommandChecks.check_is_member_moderator()
|
||||||
async def down(self, ctx: Context, member: discord.Member):
|
async def down(self, ctx: Context, member: discord.Member):
|
||||||
self._logger.debug(__name__, f"Received command level down {ctx} {member}")
|
self._logger.debug(__name__, f"Received command level down {ctx} {member}")
|
||||||
|
if ctx.guild is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}")
|
||||||
|
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module):
|
||||||
|
return
|
||||||
|
|
||||||
if member.bot:
|
if member.bot:
|
||||||
return
|
return
|
||||||
@ -436,6 +469,12 @@ class LevelGroup(DiscordCommandABC):
|
|||||||
@CommandChecks.check_is_member_moderator()
|
@CommandChecks.check_is_member_moderator()
|
||||||
async def up(self, ctx: Context, member: discord.Member):
|
async def up(self, ctx: Context, member: discord.Member):
|
||||||
self._logger.debug(__name__, f"Received command level up {ctx} {member}")
|
self._logger.debug(__name__, f"Received command level up {ctx} {member}")
|
||||||
|
if ctx.guild is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}")
|
||||||
|
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module):
|
||||||
|
return
|
||||||
|
|
||||||
if member.bot:
|
if member.bot:
|
||||||
return
|
return
|
||||||
@ -477,6 +516,12 @@ class LevelGroup(DiscordCommandABC):
|
|||||||
@CommandChecks.check_is_member_moderator()
|
@CommandChecks.check_is_member_moderator()
|
||||||
async def set(self, ctx: Context, member: discord.Member, level: str):
|
async def set(self, ctx: Context, member: discord.Member, level: str):
|
||||||
self._logger.debug(__name__, f"Received command level up {ctx} {member}")
|
self._logger.debug(__name__, f"Received command level up {ctx} {member}")
|
||||||
|
if ctx.guild is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}")
|
||||||
|
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module):
|
||||||
|
return
|
||||||
|
|
||||||
if member.bot:
|
if member.bot:
|
||||||
return
|
return
|
||||||
@ -529,5 +574,12 @@ class LevelGroup(DiscordCommandABC):
|
|||||||
@CommandChecks.check_is_member_moderator()
|
@CommandChecks.check_is_member_moderator()
|
||||||
async def reload(self, ctx: Context):
|
async def reload(self, ctx: Context):
|
||||||
self._logger.debug(__name__, f"Received command level reload {ctx}")
|
self._logger.debug(__name__, f"Received command level reload {ctx}")
|
||||||
|
if ctx.guild is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}")
|
||||||
|
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module):
|
||||||
|
return
|
||||||
|
|
||||||
await self._seed_levels(ctx)
|
await self._seed_levels(ctx)
|
||||||
self._logger.trace(__name__, f"Finished command level reload")
|
self._logger.trace(__name__, f"Finished command level reload")
|
||||||
|
@ -21,9 +21,7 @@ class LevelOnMemberJoinEvent(OnMemberJoinABC):
|
|||||||
async def on_member_join(self, member: discord.Member):
|
async def on_member_join(self, member: discord.Member):
|
||||||
self._logger.debug(__name__, f"Module {type(self)} started")
|
self._logger.debug(__name__, f"Module {type(self)} started")
|
||||||
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}")
|
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}")
|
||||||
if not FeatureFlagsSettings.get_flag_from_dict(
|
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module):
|
||||||
server_config.feature_flags, FeatureFlagsEnum.achievements_module
|
|
||||||
):
|
|
||||||
return
|
return
|
||||||
|
|
||||||
await self._level.check_level(member)
|
await self._level.check_level(member)
|
||||||
|
@ -20,10 +20,14 @@ class LevelOnMessageEvent(OnMessageABC):
|
|||||||
@EventChecks.check_is_ready()
|
@EventChecks.check_is_ready()
|
||||||
async def on_message(self, message: discord.Message):
|
async def on_message(self, message: discord.Message):
|
||||||
self._logger.debug(__name__, f"Module {type(self)} started")
|
self._logger.debug(__name__, f"Module {type(self)} started")
|
||||||
|
if message.guild is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
if message.author.bot:
|
||||||
|
return
|
||||||
|
|
||||||
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{message.guild.id}")
|
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{message.guild.id}")
|
||||||
if not FeatureFlagsSettings.get_flag_from_dict(
|
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module):
|
||||||
server_config.feature_flags, FeatureFlagsEnum.achievements_module
|
|
||||||
):
|
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -30,9 +30,7 @@ class LevelOnRawReactionAddEvent(OnRawReactionAddABC):
|
|||||||
async def on_raw_reaction_add(self, payload: RawReactionActionEvent):
|
async def on_raw_reaction_add(self, payload: RawReactionActionEvent):
|
||||||
self._logger.debug(__name__, f"Module {type(self)} started")
|
self._logger.debug(__name__, f"Module {type(self)} started")
|
||||||
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{payload.guild_id}")
|
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{payload.guild_id}")
|
||||||
if not FeatureFlagsSettings.get_flag_from_dict(
|
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module):
|
||||||
server_config.feature_flags, FeatureFlagsEnum.achievements_module
|
|
||||||
):
|
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -30,9 +30,7 @@ class LevelOnRawReactionRemoveEvent(OnRawReactionRemoveABC):
|
|||||||
async def on_raw_reaction_remove(self, payload: RawReactionActionEvent):
|
async def on_raw_reaction_remove(self, payload: RawReactionActionEvent):
|
||||||
self._logger.debug(__name__, f"Module {type(self)} started")
|
self._logger.debug(__name__, f"Module {type(self)} started")
|
||||||
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{payload.guild_id}")
|
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{payload.guild_id}")
|
||||||
if not FeatureFlagsSettings.get_flag_from_dict(
|
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module):
|
||||||
server_config.feature_flags, FeatureFlagsEnum.achievements_module
|
|
||||||
):
|
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -28,9 +28,7 @@ class LevelOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC):
|
|||||||
):
|
):
|
||||||
self._logger.debug(__name__, f"Module {type(self)} started")
|
self._logger.debug(__name__, f"Module {type(self)} started")
|
||||||
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}")
|
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{member.guild.id}")
|
||||||
if not FeatureFlagsSettings.get_flag_from_dict(
|
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.level_module):
|
||||||
server_config.feature_flags, FeatureFlagsEnum.achievements_module
|
|
||||||
):
|
|
||||||
return
|
return
|
||||||
|
|
||||||
await self._level.check_level(member)
|
await self._level.check_level(member)
|
||||||
|
Loading…
Reference in New Issue
Block a user