Added SQL command to delete all records by user id in "userjoinedvoicechannel"-table #23
This commit is contained in:
parent
71899346b2
commit
9d89135b4c
@ -35,3 +35,6 @@ class UserJoinedVoiceChannelRepositoryABC(ABC):
|
|||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def delete_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel): pass
|
def delete_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel): pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def delete_user_joined_voice_channel_by_user_id(self, user_id: int): pass
|
||||||
|
@ -119,3 +119,10 @@ class UserJoinedVoiceChannel(TableABC):
|
|||||||
DELETE FROM `UserJoinedVoiceChannel`
|
DELETE FROM `UserJoinedVoiceChannel`
|
||||||
WHERE `JoinId` = {self._join_id};
|
WHERE `JoinId` = {self._join_id};
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def delete_by_user_id_string(id: int) -> str:
|
||||||
|
return str(f"""
|
||||||
|
DELETE FROM `UserJoinedVoiceChannel`
|
||||||
|
WHERE `UserId` = {id}
|
||||||
|
""")
|
@ -121,3 +121,7 @@ class UserJoinedVoiceChannelRepositoryService(UserJoinedVoiceChannelRepositoryAB
|
|||||||
def delete_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel):
|
def delete_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel):
|
||||||
self._logger.trace(__name__, f'Send SQL command: {user_joined_voice_channel.delete_string}')
|
self._logger.trace(__name__, f'Send SQL command: {user_joined_voice_channel.delete_string}')
|
||||||
self._context.cursor.execute(user_joined_voice_channel.delete_string)
|
self._context.cursor.execute(user_joined_voice_channel.delete_string)
|
||||||
|
|
||||||
|
def delete_user_joined_voice_channel_by_user_id(self, user_id: int):
|
||||||
|
self._logger.trace(__name__, f'Send SQL command: {UserJoinedVoiceChannel.delete_by_user_id_string}')
|
||||||
|
self._context.cursor.execute(UserJoinedVoiceChannel.delete_by_user_id_string(user_id))
|
||||||
|
@ -225,7 +225,11 @@ class UserGroup(DiscordCommandABC):
|
|||||||
atr_list = [self._atr_dict["xp"]]
|
atr_list = [self._atr_dict["xp"]]
|
||||||
return [app_commands.Choice(name=atr, value=atr) for atr in atr_list]
|
return [app_commands.Choice(name=atr, value=atr) for atr in atr_list]
|
||||||
|
|
||||||
async def remove(self, ctx: context, atr: str, member: discord.Member = none):
|
@user.command()
|
||||||
|
@commands.guild_only()
|
||||||
|
@CommandChecks.check_is_ready()
|
||||||
|
@CommandChecks.check_is_member_moderator()
|
||||||
|
async def remove(self, ctx: Context, atr: str, member: discord.Member = None):
|
||||||
self._logger.debug(__name__, f'Received command user-remove {ctx}:{member}')
|
self._logger.debug(__name__, f'Received command user-remove {ctx}:{member}')
|
||||||
|
|
||||||
if member is None or not isinstance(member, discord.Member):
|
if member is None or not isinstance(member, discord.Member):
|
||||||
@ -237,9 +241,13 @@ class UserGroup(DiscordCommandABC):
|
|||||||
match atr:
|
match atr:
|
||||||
case 'xp':
|
case 'xp':
|
||||||
user.xp = 0
|
user.xp = 0
|
||||||
|
self._users.update_user(user)
|
||||||
|
self._db.save_changes()
|
||||||
|
await self._level.check_level(member)
|
||||||
|
|
||||||
case 'ontime':
|
case 'ontime':
|
||||||
# ToDo: SQL-Statement to delete all records for dcUser in user_joined_voice_channel
|
self._user_joined_voice_channel.delete_user_joined_voice_channel_by_user_id(user.user_id)
|
||||||
|
self._db.save_changes()
|
||||||
return
|
return
|
||||||
|
|
||||||
case other:
|
case other:
|
||||||
@ -248,7 +256,7 @@ class UserGroup(DiscordCommandABC):
|
|||||||
|
|
||||||
await self._message_service.send_interaction_msg(
|
await self._message_service.send_interaction_msg(
|
||||||
ctx.interaction,
|
ctx.interaction,
|
||||||
self._t.transform(f'modules.base.user.remove.{atr}').format(value, member.mention)
|
self._t.transform(f'modules.base.user.remove.{atr}').format(atr, member.mention)
|
||||||
)
|
)
|
||||||
|
|
||||||
@remove.autocomplete('atr')
|
@remove.autocomplete('atr')
|
||||||
|
Loading…
Reference in New Issue
Block a user