Skip to content

Commit

Permalink
Release/1.4.1 - New Discord Format Usernames (#11)
Browse files Browse the repository at this point in the history
Support new Discord format usernames with "#0" user discriminators as returned by the Discord API durning rollover period.
  • Loading branch information
jacobpretorius authored Jul 15, 2023
1 parent 795a644 commit 4049005
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "XRPL-Discord-Bot",
"version": "1.4.0",
"version": "1.4.1",
"description": "A customisable open-source Discord bot that brings the power of the XRPL to Discord communities.",
"repository": {
"type": "git",
Expand Down
8 changes: 8 additions & 0 deletions src/utils/getUserNameFromAdminLinkWalletCommand.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,12 @@ describe('getUserNameFromAdminLinkWalletCommand util', () => {
)
).toEqual({ username: 'user', tag: '1234' });
});
it('should return an object with username and tag with new format', () => {
expect(
getUserNameFromAdminLinkWalletCommand(
'adminlinkwallet rnruxxaTbJUMNtFNBJ7X2xSiy1KE7ajUuH user',
'rnruxxaTbJUMNtFNBJ7X2xSiy1KE7ajUuH'
)
).toEqual({ username: 'user', tag: '0' });
});
});
2 changes: 1 addition & 1 deletion src/utils/getUserNameFromAdminLinkWalletCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const getUserNameFromAdminLinkWalletCommand = (

return {
username: username.split('#')[0],
tag: username.split('#')[1],
tag: username.split('#')[1] ?? '0',
};
};

Expand Down
18 changes: 18 additions & 0 deletions src/utils/getUserNameFromGetWalletCommand.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,22 @@ describe('getUserNameFromGetWalletCommand util', () => {
tag: '1234',
});
});
it('should return an object with username with new format', () => {
expect(getUserNameFromGetWalletCommand('getwallet user')).toEqual({
username: 'user',
tag: '0',
});
expect(getUserNameFromGetWalletCommand('Getwallet user')).toEqual({
username: 'user',
tag: '0',
});
expect(getUserNameFromGetWalletCommand('get wallet user')).toEqual({
username: 'user',
tag: '0',
});
expect(getUserNameFromGetWalletCommand('Get wallet user')).toEqual({
username: 'user',
tag: '0',
});
});
});
2 changes: 1 addition & 1 deletion src/utils/getUserNameFromGetWalletCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const getUserNameFromGetWalletCommand = (message: string) => {

return {
username: username.split('#')[0],
tag: username.split('#')[1],
tag: username.split('#')[1] ?? '0',
};
};

Expand Down

0 comments on commit 4049005

Please sign in to comment.