diff --git a/src/bot.ts b/src/bot.ts index f4529d7d3b4f88c51c5c80878c30082b2fb566aa..cc4baa80fc852b73fefb0d64482a371375dd992c 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -193,10 +193,16 @@ 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) { + 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;