@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
16
17
- import { User , GuildMember } from "better-discord.js" ;
17
+ import { User , GuildMember , Message } from "better-discord.js" ;
18
18
import { DiscordBot } from "./bot" ;
19
19
import { Util } from "./util" ;
20
20
import { DiscordBridgeConfig } from "./config" ;
@@ -96,8 +96,8 @@ export class UserSyncroniser {
96
96
* @returns {Promise<void> }
97
97
* @constructor
98
98
*/
99
- public async OnUpdateUser ( discordUser : User , isWebhook : boolean = false ) {
100
- const userState = await this . GetUserUpdateState ( discordUser , isWebhook ) ;
99
+ public async OnUpdateUser ( discordUser : User , isWebhook : boolean = false , msg ?: Message ) {
100
+ const userState = await this . GetUserUpdateState ( discordUser , isWebhook , msg ) ;
101
101
try {
102
102
await this . ApplyStateToProfile ( userState ) ;
103
103
} catch ( e ) {
@@ -230,7 +230,7 @@ export class UserSyncroniser {
230
230
}
231
231
}
232
232
233
- public async GetUserUpdateState ( discordUser : User , isWebhook : boolean = false ) : Promise < IUserState > {
233
+ public async GetUserUpdateState ( discordUser : User , isWebhook : boolean = false , msg ?: Message ) : Promise < IUserState > {
234
234
log . verbose ( `State update requested for ${ discordUser . id } ` ) ;
235
235
let mxidExtra = "" ;
236
236
if ( isWebhook ) {
@@ -244,7 +244,7 @@ export class UserSyncroniser {
244
244
id : discordUser . id + mxidExtra ,
245
245
mxUserId : `@_discord_${ discordUser . id } ${ mxidExtra } :${ this . config . bridge . domain } ` ,
246
246
} ) ;
247
- const displayName = Util . ApplyPatternString ( this . config . ghosts . usernamePattern , {
247
+ const displayName = msg ?. member ?. nickname || Util . ApplyPatternString ( this . config . ghosts . usernamePattern , {
248
248
id : discordUser . id ,
249
249
tag : discordUser . discriminator ,
250
250
username : discordUser . username ,
0 commit comments