Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions lib/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,7 @@ class Bot {

const user = this.discord.users.find('username', search);
if (user) {
const nickname = guild.members.get(user.id).nickname;
if (!nickname || nickname === search) {
return user;
}
return user;
}

return match;
Expand Down
6 changes: 3 additions & 3 deletions test/bot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,15 +400,15 @@ describe('Bot', function () {
this.sendMessageStub.should.have.been.calledWith(expected);
});

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

const username = 'ircuser';
const text = 'Hello, @username!';
const expected = `**<${username}>** Hello, @username!`;
const text = 'Hello, @testuser!';
const expected = `**<${username}>** Hello, <@${testUser.id}>!`;

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