Skip to content

Commit

Permalink
Prefer server-level display names when available
Browse files Browse the repository at this point in the history
Signed-off-by: Bob Arctor <[email protected]>
  • Loading branch information
TheStranjer committed Jun 18, 2023
1 parent ece29f4 commit 866de2f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/888.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prefer server-level display names when available
2 changes: 1 addition & 1 deletion src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ export class DiscordBot {
}

// Update presence because sometimes discord misses people.
await this.userSync.OnUpdateUser(msg.author, Boolean(msg.webhookID));
await this.userSync.OnUpdateUser(msg.author, Boolean(msg.webhookID), msg);
let rooms: string[];
try {
rooms = await this.channelSync.GetRoomIdsFromChannel(msg.channel);
Expand Down
7 changes: 5 additions & 2 deletions src/usersyncroniser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { User, GuildMember } from "better-discord.js";
import { User, GuildMember, Message } from "better-discord.js";
import { DiscordBot } from "./bot";
import { Util } from "./util";
import { DiscordBridgeConfig } from "./config";
Expand Down Expand Up @@ -96,8 +96,11 @@ export class UserSyncroniser {
* @returns {Promise<void>}
* @constructor
*/
public async OnUpdateUser(discordUser: User, isWebhook: boolean = false) {
public async OnUpdateUser(discordUser: User, isWebhook: boolean = false, msg?: Message) {
const userState = await this.GetUserUpdateState(discordUser, isWebhook);
if (msg?.member?.nickname) {
userState.displayName = msg.member.nickname;
}
try {
await this.ApplyStateToProfile(userState);
} catch (e) {
Expand Down

0 comments on commit 866de2f

Please sign in to comment.