Skip to content

Commit bc3f517

Browse files
authored
Merge pull request #208 from Throne3d/fix/username-mentions
Convert username mentions even if nickname set
2 parents 1daf62e + 8ef4ba9 commit bc3f517

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

lib/bot.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,7 @@ class Bot {
220220

221221
const user = this.discord.users.find('username', search);
222222
if (user) {
223-
const nickname = guild.members.get(user.id).nickname;
224-
if (!nickname || nickname === search) {
225-
return user;
226-
}
223+
return user;
227224
}
228225

229226
const role = guild.roles.find('name', search);

test/bot.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,15 +484,15 @@ describe('Bot', function () {
484484
this.sendMessageStub.should.have.been.calledWith(expected);
485485
});
486486

487-
it('should not convert username mentions from IRC if nickname differs', function () {
487+
it('should convert username mentions from IRC even if nickname differs', function () {
488488
const testUser = new discord.User(this.bot.discord, { username: 'testuser', id: '123', nickname: 'somenickname' });
489489
this.findUserStub.withArgs('username', testUser.username).returns(testUser);
490490
this.findUserStub.withArgs('nickname', 'somenickname').returns(testUser);
491491
this.findUserStub.withArgs('id', testUser.id).returns(testUser);
492492

493493
const username = 'ircuser';
494-
const text = 'Hello, @username!';
495-
const expected = `**<${username}>** Hello, @username!`;
494+
const text = 'Hello, @testuser!';
495+
const expected = `**<${username}>** Hello, <@${testUser.id}>!`;
496496

497497
this.bot.sendToDiscord(username, '#irc', text);
498498
this.sendMessageStub.should.have.been.calledWith(expected);

0 commit comments

Comments
 (0)