-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pending changes exported from your codespace
- Loading branch information
Showing
3 changed files
with
375 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import parser from "qs"; | ||
|
||
/** | ||
* ID - The main identifier, this is required. Prefix = I: | ||
* [I]=member* | ||
* | ||
* SUBID - This is not required: Prefix = S: | ||
* *[S]=0* - No SUBID ; *[S]=whois WITH SUBID | ||
* | ||
* ARGS - This is not required: Prefix = A: | ||
* *A[username]=0sapphy&A[command]=whois | ||
* | ||
* How id arguments string should be formatted: | ||
* | ||
* @example | ||
* new Builder() | ||
* .setCustomId("[I]=member&[S]=whois&A[userId]=1234") // With ID, SUBID & ARGS | ||
* .setCustomId("[I]=member&[S]=whois") // With ID & SUBID | ||
* .setCustomId("[I]=member&A[username]=0sapphy&A[command]=whois") // With ID & MULTI-ARGS | ||
*/ | ||
export function Parse(id: string) { | ||
return parser.parse(id) as { I: string; S?: string; A?: object } | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function CompileArguments(A: any) { | ||
const args = {}; | ||
for (const ARG of Object.keys(A)) { | ||
Object.assign(args, { [ARG]: A[ARG] }) | ||
} | ||
|
||
return args; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.