-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vanity): Cache urls to reduce requests
- Loading branch information
Marco Crespi
committed
Mar 30, 2020
1 parent
654e993
commit 55d0560
Showing
4 changed files
with
24 additions
and
25 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
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,17 @@ | ||
import { Cache } from '../../framework/cache/Cache'; | ||
|
||
export class VanityUrlCache extends Cache<string> { | ||
public async init() { | ||
// NO-OP | ||
} | ||
|
||
protected async _get(guildId: string): Promise<string> { | ||
return ( | ||
this.client.guilds.get(guildId)?.vanityURL || | ||
this.client | ||
.getGuildVanity(guildId) | ||
.then((r) => r.code as any) | ||
.catch(() => null) | ||
); | ||
} | ||
} |
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
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