Levelsystem per Befehl neuladen #164 #175
No reviewers
Labels
No Label
MVP
web-interface
bug
bugfix
cli
discussion
documentation
duplicate
expense
high
expense
low
expense
medium
expense
very-high
help wanted
improvement
invalid
priority
blocker
priority
high
priority
low
priority
medium
question
refactoring
release
story
wontfix
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sh-edraft.de/sh_discord_bot#175
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "#164"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
#164
@ -22,1 +22,3 @@
async def send_channel_message(self, channel: discord.TextChannel, message: Union[str, discord.Embed], without_tracking=True): pass
async def send_channel_message(
self, channel: discord.TextChannel, message: Union[str, discord.Embed], without_tracking=True
): pass
Formatierung
@ -26,0 +27,4 @@
async def send_dm_message(
self, message: Union[str, discord.Embed], receiver: Union[discord.User, discord.Member],
without_tracking=False
): pass
Formatierung
Kann so bleiben
@ -29,0 +34,4 @@
self, ctx: Context, message: Union[str, discord.Embed], file: discord.File = None,
is_persistent: bool = False, is_public: bool = False, wait_before_delete: int = None,
without_tracking=True
) -> Optional[discord.Message]: pass
Formatierung
@ -32,0 +41,4 @@
self, interaction: Interaction, message: Union[str, discord.Embed],
is_persistent: bool = False, is_public: bool = False, wait_before_delete: int = None,
without_tracking=True, **kwargs
): pass
Formatierung
@ -38,0 +37,4 @@
guild_id = \
message.guild.id if message.guild is not None else \
message.channel.guild.id if message.channel is not None and message.channel.guild is not None else \
message.reference.guild_id if message.reference is not None else None
Hier noch evtl. prüfen bei
ob
?
Also
Ist ja auch bei Zeile 39 der Fall.
@ -169,2 +183,3 @@
self._logger.debug(__name__, f'Level with name {level.name} already exists')
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.error.level_with_name_already_exists').format(level.name))
await self._message_service.send_ctx_msg(ctx, self._t.transform(
'modules.level.error.level_with_name_already_exists').format(level.name))
Formatierung
@ -173,2 +188,3 @@
found_level = levels.where(lambda l: l.min_xp == level.min_xp).first_or_default()
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.error.level_with_xp_already_exists').format(found_level.name, found_level.min_xp))
await self._message_service.send_ctx_msg(ctx, self._t.transform(
'modules.level.error.level_with_xp_already_exists').format(found_level.name, found_level.min_xp))
Formatierung
@ -178,2 +194,3 @@
self._db.save_changes()
self._logger.info(__name__, f'Saved level {name} with color {color}, min_xp {min_xp} and permissions {permissions}')
self._logger.info(__name__,
f'Saved level {name} with color {color}, min_xp {min_xp} and permissions {permissions}')
Formatierung
@ -181,1 +198,3 @@
self._logger.error(__name__, f'Could not save level {name} with color {color}, min_xp {min_xp} and permissions {permissions}', e)
self._logger.error(__name__,
f'Could not save level {name} with color {color}, min_xp {min_xp} and permissions {permissions}',
e)
Formatierung
@ -184,1 +202,3 @@
await self._seed_levels(ctx.channel)
await self._message_service.send_ctx_msg(ctx,
self._t.transform('modules.level.create.created').format(name,
permissions))
Formatierung
@ -188,2 +209,3 @@
@create.autocomplete('color')
async def create_color_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]:
async def create_color_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[
app_commands.Choice[str]]:
Formatierung
@ -191,2 +213,3 @@
# https://discordpy.readthedocs.io/en/latest/api.html#discord.Colour.to_rgb
return [app_commands.Choice(name=self._t.transform(f'common.colors.{color}'), value=f'rgb({code[0]}, {code[1]}, {code[2]})') for color, code in self._colors]
return [app_commands.Choice(name=self._t.transform(f'common.colors.{color}'),
value=f'rgb({code[0]}, {code[1]}, {code[2]})') for color, code in self._colors]
Formatierung
@ -197,2 +220,3 @@
@CommandChecks.check_is_member_admin()
async def edit(self, ctx: Context, level: str, name: str = None, color: str = None, min_xp: int = None, permissions: int = None):
async def edit(self, ctx: Context, level: str, name: str = None, color: str = None, min_xp: int = None,
permissions: int = None):
Formatierung
@ -201,2 +225,3 @@
server = self._servers.get_server_by_discord_id(ctx.guild.id)
level_from_db = self._levels.get_levels_by_server_id(server.server_id).where(lambda l: l.name == level).single_or_default()
level_from_db = self._levels.get_levels_by_server_id(server.server_id).where(
lambda l: l.name == level).single_or_default()
Formatierung
@ -203,2 +228,3 @@
if level_from_db is None:
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.edit.not_found').format(level))
await self._message_service.send_ctx_msg(ctx,
self._t.transform('modules.level.edit.not_found').format(level))
Formatierung
@ -217,1 +243,3 @@
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.edit.color_invalid').format(color))
await self._message_service.send_ctx_msg(ctx,
self._t.transform('modules.level.edit.color_invalid').format(
color))
Formatierung
@ -227,2 +255,3 @@
except Exception as e:
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.edit.permission_invalid').format(permissions))
await self._message_service.send_ctx_msg(ctx, self._t.transform(
'modules.level.edit.permission_invalid').format(permissions))
Formatierung
@ -234,2 +263,3 @@
self._db.save_changes()
await role.edit(name=level_from_db.name, permissions=discord.Permissions(level_from_db.permissions), colour=discord.Colour(int(level_from_db.color, 16)))
await role.edit(name=level_from_db.name, permissions=discord.Permissions(level_from_db.permissions),
colour=discord.Colour(int(level_from_db.color, 16)))
Formatierung
@ -239,1 +269,3 @@
self._logger.error(__name__, f'Could not save level {level} with color {color}, min_xp {min_xp} and permissions {permissions}', e)
self._logger.error(__name__,
f'Could not save level {level} with color {color}, min_xp {min_xp} and permissions {permissions}',
e)
Formatierung
@ -246,2 +278,3 @@
@edit.autocomplete('level')
async def edit_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]:
async def edit_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[
app_commands.Choice[str]]:
Formatierung
@ -250,2 +283,3 @@
@edit.autocomplete('color')
async def edit_color_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]:
async def edit_color_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[
app_commands.Choice[str]]:
Formatierung
@ -253,2 +287,3 @@
# https://discordpy.readthedocs.io/en/latest/api.html#discord.Colour.to_rgb
return [app_commands.Choice(name=self._t.transform(f'common.colors.{color}'), value=f'rgb({code[0]}, {code[1]}, {code[2]})') for color, code in self._colors]
return [app_commands.Choice(name=self._t.transform(f'common.colors.{color}'),
value=f'rgb({code[0]}, {code[1]}, {code[2]})') for color, code in self._colors]
Formatierung
@ -263,2 +298,3 @@
server = self._servers.get_server_by_discord_id(ctx.guild.id)
level_from_db = self._levels.get_levels_by_server_id(server.server_id).where(lambda l: l.name == level).first_or_default()
level_from_db = self._levels.get_levels_by_server_id(server.server_id).where(
lambda l: l.name == level).first_or_default()
Formatierung
@ -267,1 +303,3 @@
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.remove.error.not_found').format(level))
await self._message_service.send_ctx_msg(ctx,
self._t.transform('modules.level.remove.error.not_found').format(
level))
Formatierung
@ -282,2 +320,2 @@
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.remove.success').format(level))
await self._seed_levels(ctx.channel)
await self._message_service.send_ctx_msg(ctx,
self._t.transform('modules.level.remove.success').format(level))
Formatierung
@ -287,2 +326,3 @@
@remove.autocomplete('level')
async def remove_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]:
async def remove_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[
app_commands.Choice[str]]:
Formatierung
@ -306,2 +346,3 @@
if level == levels.first():
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.down.already_first').format(member.mention))
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.down.already_first').format(
member.mention))
Formatierung
@ -315,2 +356,3 @@
self._db.save_changes()
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.down.success').format(member.mention, new_level.name))
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.down.success').format(
member.mention, new_level.name))
Formatierung
@ -319,2 +361,3 @@
self._logger.error(__name__, f'Cannot level down {member.name} with level {level.name}', e)
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.down.failed').format(member.mention))
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.down.failed').format(
member.mention))
Formatierung
@ -339,2 +382,3 @@
if level.name == levels.last().name:
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.up.already_last').format(member.mention))
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.up.already_last').format(
member.mention))
Formatierung
@ -348,2 +392,3 @@
self._db.save_changes()
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.up.success').format(member.mention, new_level.name))
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.up.success').format(
member.mention, new_level.name))
Formatierung
@ -352,2 +397,3 @@
self._logger.error(__name__, f'Cannot level up {member.name} with level {level.name}', e)
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.up.failed').format(member.mention))
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.up.failed').format(
member.mention))
Formatierung
@ -369,2 +415,3 @@
current_level = self._level_service.get_level(user)
new_level = self._levels.get_levels_by_server_id(server.server_id).where(lambda l: l.name == level).single_or_default()
new_level = self._levels.get_levels_by_server_id(server.server_id).where(
lambda l: l.name == level).single_or_default()
Formatierung
@ -372,2 +419,3 @@
if new_level is None:
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.set.not_found').format(level))
await self._message_service.send_ctx_msg(ctx,
self._t.transform('modules.level.set.not_found').format(level))
Formatierung
@ -377,2 +425,3 @@
if current_level.name == level:
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.set.already_level').format(member.mention, level))
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.set.already_level').format(
member.mention, level))
Formatierung
@ -385,2 +434,3 @@
self._db.save_changes()
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.set.success').format(member.mention, new_level.name))
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.set.success').format(
member.mention, new_level.name))
Formatierung
@ -389,2 +439,3 @@
self._logger.error(__name__, f'Cannot set level {level} for {member.name}', e)
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.set.failed').format(member.mention))
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.set.failed').format(
member.mention))
Formatierung