Skip to content

Commit

Permalink
Merge pull request #208 from Throne3d/fix/username-mentions
Browse files Browse the repository at this point in the history
Convert username mentions even if nickname set
  • Loading branch information
ekmartin authored Mar 29, 2017
2 parents 1daf62e + 8ef4ba9 commit bc3f517
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 1 addition & 4 deletions lib/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,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;
}

const role = guild.roles.find('name', search);
Expand Down
6 changes: 3 additions & 3 deletions test/bot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,15 +484,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

0 comments on commit bc3f517

Please sign in to comment.