Merge pull request '0.3 - Bei message Member.name -> Member.mentions oder so (#100)' (#137) from #100 into 0.3

Reviewed-on: sh-edraft.de/kd_discord_bot#137
Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com>
Closes #100
This commit is contained in:
Sven Heidemann 2022-11-22 18:16:38 +01:00
commit 4a0f5c28c1
6 changed files with 30 additions and 15 deletions

View File

@ -98,7 +98,7 @@ class AutoRoleGroup(DiscordCommandABC):
message = List(discord.Message, [message async for message in channel.history(limit=50)]).where(lambda m: m.id == int(message_id)).single_or_default() message = List(discord.Message, [message async for message in channel.history(limit=50)]).where(lambda m: m.id == int(message_id)).single_or_default()
if message is None: if message is None:
self._logger.debug(__name__, f'Message with id {message_id} not found in {channel.name}') self._logger.debug(__name__, f'Message with id {message_id} not found in {channel.name}')
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.auto_role.add.error.not_found').format(message_id, channel.name)) await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.auto_role.add.error.not_found').format(message_id, channel.mention))
self._logger.trace(__name__, f'Finished command auto-role add') self._logger.trace(__name__, f'Finished command auto-role add')
return return
@ -250,7 +250,7 @@ class AutoRoleGroup(DiscordCommandABC):
except Exception as e: except Exception as e:
self._logger.error(__name__, f'Cannot add reaction {rule.emoji_name} to message: {auto_role_from_db.discord_message_id}', e) self._logger.error(__name__, f'Cannot add reaction {rule.emoji_name} to message: {auto_role_from_db.discord_message_id}', e)
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.auto_role.rule.add.success').format(emoji, role.name, auto_role)) await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.auto_role.rule.add.success').format(emoji, role.mention, auto_role))
self._logger.trace(__name__, f'Finished command auto-role rule add') self._logger.trace(__name__, f'Finished command auto-role rule add')
@add.autocomplete('auto_role') @add.autocomplete('auto_role')

View File

@ -70,10 +70,10 @@ class BaseOnMemberJoinEvent(OnMemberJoinABC):
await self._messenger.send_dm_message(self._t.transform('modules.base.welcome_message').format(member.guild.name), member) await self._messenger.send_dm_message(self._t.transform('modules.base.welcome_message').format(member.guild.name), member)
for admin in self._permission_service.get_admins(member.guild.id): for admin in self._permission_service.get_admins(member.guild.id):
await self._messenger.send_dm_message(self._t.transform('modules.base.welcome_message_for_team').format(member.name), admin) await self._messenger.send_dm_message(self._t.transform('modules.base.welcome_message_for_team').format(member.mention), admin)
for moderator in self._permission_service.get_moderators(member.guild.id): for moderator in self._permission_service.get_moderators(member.guild.id):
await self._messenger.send_dm_message(self._t.transform('modules.base.welcome_message_for_team').format(member.name), moderator) await self._messenger.send_dm_message(self._t.transform('modules.base.welcome_message_for_team').format(member.mention), moderator)
try: try:
server = self._servers.get_server_by_discord_id(member.guild.id) server = self._servers.get_server_by_discord_id(member.guild.id)

View File

@ -46,7 +46,7 @@ class BaseOnVoiceStateUpdateEventHelpChannel(OnVoiceStateUpdateABC):
mods = [*self._permissions.get_admins(member.guild.id), *self._permissions.get_moderators(member.guild.id)] mods = [*self._permissions.get_admins(member.guild.id), *self._permissions.get_moderators(member.guild.id)]
for a in mods: for a in mods:
await self._message_service.send_dm_message( await self._message_service.send_dm_message(
self._t.transform('modules.base.member_joined_help_voice_channel').format(member.name), self._t.transform('modules.base.member_joined_help_voice_channel').format(member.mention),
a, a,
) )

View File

@ -303,7 +303,7 @@ class LevelGroup(DiscordCommandABC):
levels = self._levels.get_levels_by_server_id(server.server_id).order_by(lambda l: l.min_xp) levels = self._levels.get_levels_by_server_id(server.server_id).order_by(lambda l: l.min_xp)
if level == levels.first(): if level == levels.first():
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.down.already_first').format(member.name)) await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.down.already_first').format(member.mention))
self._logger.trace(__name__, f'Finished command level down') self._logger.trace(__name__, f'Finished command level down')
return return
@ -312,11 +312,11 @@ class LevelGroup(DiscordCommandABC):
user.xp = new_level.min_xp user.xp = new_level.min_xp
self._users.update_user(user) self._users.update_user(user)
self._db.save_changes() self._db.save_changes()
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.down.success').format(member.name, new_level.name)) await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.down.success').format(member.mention, new_level.name))
await self._level_service.set_level(user) await self._level_service.set_level(user)
except Exception as e: except Exception as e:
self._logger.error(__name__, f'Cannot level down {member.name} with level {level.name}', e) 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.name)) await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.down.failed').format(member.mention))
self._logger.trace(__name__, f'Finished command level down') self._logger.trace(__name__, f'Finished command level down')
@ -336,7 +336,7 @@ class LevelGroup(DiscordCommandABC):
levels = self._levels.get_levels_by_server_id(server.server_id).order_by(lambda l: l.min_xp) levels = self._levels.get_levels_by_server_id(server.server_id).order_by(lambda l: l.min_xp)
if level.name == levels.last().name: if level.name == levels.last().name:
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.up.already_last').format(member.name)) await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.up.already_last').format(member.mention))
self._logger.trace(__name__, f'Finished command level up') self._logger.trace(__name__, f'Finished command level up')
return return
@ -345,11 +345,11 @@ class LevelGroup(DiscordCommandABC):
user.xp = new_level.min_xp user.xp = new_level.min_xp
self._users.update_user(user) self._users.update_user(user)
self._db.save_changes() self._db.save_changes()
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.up.success').format(member.name, new_level.name)) await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.up.success').format(member.mention, new_level.name))
await self._level_service.set_level(user) await self._level_service.set_level(user)
except Exception as e: except Exception as e:
self._logger.error(__name__, f'Cannot level up {member.name} with level {level.name}', e) 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.name)) await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.up.failed').format(member.mention))
self._logger.trace(__name__, f'Finished command level up') self._logger.trace(__name__, f'Finished command level up')
@ -374,7 +374,7 @@ class LevelGroup(DiscordCommandABC):
return return
if current_level.name == level: if current_level.name == level:
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.set.already_level').format(member.name, level)) await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.set.already_level').format(member.mention, level))
self._logger.trace(__name__, f'Finished command level set') self._logger.trace(__name__, f'Finished command level set')
return return
@ -382,11 +382,11 @@ class LevelGroup(DiscordCommandABC):
user.xp = new_level.min_xp user.xp = new_level.min_xp
self._users.update_user(user) self._users.update_user(user)
self._db.save_changes() self._db.save_changes()
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.set.success').format(member.name, new_level.name)) await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.set.success').format(member.mention, new_level.name))
await self._level_service.set_level(user) await self._level_service.set_level(user)
except Exception as e: except Exception as e:
self._logger.error(__name__, f'Cannot set level {level} for {member.name}', e) 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.name)) await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.level.set.failed').format(member.mention))
self._logger.trace(__name__, f'Finished command level set') self._logger.trace(__name__, f'Finished command level set')

View File

@ -0,0 +1,13 @@
import { NgModule } from "@angular/core";
import { RouterModule, Routes } from "@angular/router";
import { MembersComponent } from "./component/members/members.component";
const routes: Routes = [
{ path: '', component: MembersComponent },
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class MembersRoutingModule { }

View File

@ -1,9 +1,11 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router'; import { RouterModule, Routes } from '@angular/router';
import { ServerDashboardComponent } from './server-dashboard/server-dashboard.component'; import { ServerDashboardComponent } from './server-dashboard/server-dashboard.component';
import { AuthGuard } from "../../shared/guards/auth/auth.guard";
const routes: Routes = [ const routes: Routes = [
{ path: '', component: ServerDashboardComponent } { path: '', component: ServerDashboardComponent },
{ path: 'members', loadChildren: () => import('./members/members.module').then(m => m.MembersModule), canActivate: [AuthGuard] },
]; ];
@NgModule({ @NgModule({