mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
feat: use a standard custom ID format in role buttons
This commit is contained in:
parent
784c54b22a
commit
b64611dd01
4 changed files with 30 additions and 3 deletions
17
backend/src/utils/parseCustomId.ts
Normal file
17
backend/src/utils/parseCustomId.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
const customIdFormat = /^([^:]+):\d+:(.*)$/;
|
||||
|
||||
export function parseCustomId(customId: string): { namespace: string; data: any } {
|
||||
const parts = customId.match(customIdFormat);
|
||||
if (!parts) {
|
||||
return {
|
||||
namespace: "",
|
||||
data: null,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
namespace: parts[1],
|
||||
// Skipping timestamp
|
||||
data: JSON.parse(parts[2]),
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue