File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 14
14
* for other functions to use the information. A great use of this would be provide a `guildID`
15
15
* parameter and pass it on to an error directly without searching for it in the URL. In code,
16
16
* this could look like this:
17
- *
17
+ *
18
18
* ```ts
19
19
* async function fetchAndHandleError<T>(ctx: Context, url: string): Promise<T> {
20
20
* const response = await fetch(url);
29
29
* // Default error.
30
30
* throw 'There was an error, but it could not be identified.';
31
31
* }
32
- *
32
+ *
33
33
* async function guildName(guildID: StringifiedNumber): Promise<string> {
34
34
* const response = await fetchAndHandleError<Guild.GET.Guild>(
35
35
* new Context({ guildID }),
36
36
* `https://pylon.bot/api/guilds/${guildID}`,
37
37
* );
38
38
* return response.name;
39
39
* }
40
- *
40
+ *
41
41
* const guildID: StringifiedNumber = '0';
42
42
* console.log(await guildName(guildID));
43
43
* ```
44
- *
44
+ *
45
45
* Here, {@linkcode Context} is leveraged to discover what the `guildID` parameter was
46
46
* without searching through the URL (where, it may possibly return a wrong parsed value,
47
47
* like a regex edge case). It provided environmental parameters directly to eliminate
You can’t perform that action at this time.
0 commit comments