diff --git a/src/bot.ts b/src/bot.ts index 51237ec7f39e53b1cf7a8a98b3da6b85babb812b..045f1cfbb509b15afe77508dde980822884cc86d 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -191,10 +191,18 @@ export class DiscordBot { const mxClient = this.bridge.getClientFactory().getClientAs(); log.verbose("DiscordBot", `Looking up ${guildId}_${channelId}`); const result = await this.LookupRoom(guildId, channelId, event.sender); - log.verbose("DiscordBot", `Found channel! Looking up ${event.sender}`); const chan = result.channel; const botUser = result.botUser; - const profile = result.botUser ? await mxClient.getProfileInfo(event.sender) : null; + let profile = null; + if (result.botUser) { + // We are doing this through webhooks so fetch the user profile. + profile = await mxClient.getStateEvent(event.room_id, "m.room.member", event.sender); + if (profile !== null) { + profile = profile.content; + } else { + log.warn("DiscordBot", `User ${event.sender} has no member state. That's odd.`); + } + } const embed = this.MatrixEventToEmbed(event, profile, chan); const opts: Discord.MessageOptions = {}; const hasAttachment = ["m.image", "m.audio", "m.video", "m.file"].indexOf(event.content.msgtype) !== -1;