Skip to content

Commit 4049005

Browse files
Release/1.4.1 - New Discord Format Usernames (#11)
Support new Discord format usernames with "#0" user discriminators as returned by the Discord API durning rollover period.
1 parent 795a644 commit 4049005

6 files changed

+31
-5
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "XRPL-Discord-Bot",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"description": "A customisable open-source Discord bot that brings the power of the XRPL to Discord communities.",
55
"repository": {
66
"type": "git",

src/utils/getUserNameFromAdminLinkWalletCommand.test.ts

+8
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,12 @@ describe('getUserNameFromAdminLinkWalletCommand util', () => {
1919
)
2020
).toEqual({ username: 'user', tag: '1234' });
2121
});
22+
it('should return an object with username and tag with new format', () => {
23+
expect(
24+
getUserNameFromAdminLinkWalletCommand(
25+
'adminlinkwallet rnruxxaTbJUMNtFNBJ7X2xSiy1KE7ajUuH user',
26+
'rnruxxaTbJUMNtFNBJ7X2xSiy1KE7ajUuH'
27+
)
28+
).toEqual({ username: 'user', tag: '0' });
29+
});
2230
});

src/utils/getUserNameFromAdminLinkWalletCommand.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const getUserNameFromAdminLinkWalletCommand = (
1414

1515
return {
1616
username: username.split('#')[0],
17-
tag: username.split('#')[1],
17+
tag: username.split('#')[1] ?? '0',
1818
};
1919
};
2020

src/utils/getUserNameFromGetWalletCommand.test.ts

+18
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,22 @@ describe('getUserNameFromGetWalletCommand util', () => {
2323
tag: '1234',
2424
});
2525
});
26+
it('should return an object with username with new format', () => {
27+
expect(getUserNameFromGetWalletCommand('getwallet user')).toEqual({
28+
username: 'user',
29+
tag: '0',
30+
});
31+
expect(getUserNameFromGetWalletCommand('Getwallet user')).toEqual({
32+
username: 'user',
33+
tag: '0',
34+
});
35+
expect(getUserNameFromGetWalletCommand('get wallet user')).toEqual({
36+
username: 'user',
37+
tag: '0',
38+
});
39+
expect(getUserNameFromGetWalletCommand('Get wallet user')).toEqual({
40+
username: 'user',
41+
tag: '0',
42+
});
43+
});
2644
});

src/utils/getUserNameFromGetWalletCommand.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const getUserNameFromGetWalletCommand = (message: string) => {
1212

1313
return {
1414
username: username.split('#')[0],
15-
tag: username.split('#')[1],
15+
tag: username.split('#')[1] ?? '0',
1616
};
1717
};
1818

0 commit comments

Comments
 (0)