Added logic to count moved users to mass move (#156) #157

Merged
edraft merged 1 commits from #156 into 0.3 2023-01-04 11:29:50 +01:00
4 changed files with 16 additions and 1 deletions
Showing only changes of commit f3eff97780 - Show all commits

@ -1 +1 @@
Subproject commit c8983770f7a41f84441e6b60cdfe5eb694039f1c
Subproject commit 0b18f8e5963bb963779968f102579d797016ccb6

View File

@ -14,6 +14,9 @@ class ClientUtilsServiceABC(ABC):
@abstractmethod
def moved_user(self, guild_id: int): pass
@abstractmethod
def moved_users(self, guild_id: int, count: int): pass
@abstractmethod
def get_client(self, dc_ic: int, guild_id: int): pass

View File

@ -54,6 +54,13 @@ class ClientUtilsService(ClientUtilsServiceABC):
self._clients.update_client(client)
self._db.save_changes()
def moved_users(self, guild_id: int, count: int):
server = self._servers.get_server_by_discord_id(guild_id)
client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.server_id)
client.moved_users_count += count
self._clients.update_client(client)
self._db.save_changes()
def get_client(self, dc_ic: int, guild_id: int):
server = self._servers.get_server_by_discord_id(guild_id)
client = self._clients.find_client_by_discord_id_and_server_id(self._bot.user.id, server.server_id)

View File

@ -10,6 +10,7 @@ from discord.ext.commands import Context
from bot_core.abc.message_service_abc import MessageServiceABC
from bot_core.helper.command_checks import CommandChecks
from bot_core.logging.command_logger import CommandLogger
from bot_core.service.client_utils_service import ClientUtilsService
class MassMoveCommand(DiscordCommandABC):
@ -20,12 +21,14 @@ class MassMoveCommand(DiscordCommandABC):
message_service: MessageServiceABC,
bot: DiscordBotServiceABC,
translate: TranslatePipe,
client_utils: ClientUtilsService
):
DiscordCommandABC.__init__(self)
self._logger = logger
self._message_service = message_service
self._bot = bot
self._t = translate
self._client_utils = client_utils
@commands.hybrid_command(name='mass-move')
@CommandChecks.check_is_ready()
@ -42,7 +45,9 @@ class MassMoveCommand(DiscordCommandABC):
channel_from = ctx.author.voice.channel
moves = [member.move_to(channel_to) for member in channel_from.members]
move_count = len(moves)
await asyncio.gather(*moves)
self._client_utils.moved_users(ctx.guild.id, move_count)
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.base.mass_move.moved').format(channel_from.mention, channel_to.mention))