Skip to content

Commit

Permalink
Add ability to disable update warning
Browse files Browse the repository at this point in the history
  • Loading branch information
pakkographic committed Jun 28, 2024
1 parent 2ed8836 commit 7ac07dd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/structures/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export class Client extends TypedEmitter<ClientEvents> {
ForceDisableREST: params.ForceDisableREST ?? false,
RESTOptions: params.RESTOptions,
connectionMessage: params.connectionMessage ?? true,
updateWarning: params.updateWarning ?? true,
waitForCaching: params.waitForCaching ?? true,
isOfficialMarkdownEnabled: params.isOfficialMarkdownEnabled ?? true,
collectionLimits: {
Expand Down Expand Up @@ -200,6 +201,7 @@ export class Client extends TypedEmitter<ClientEvents> {
version: string;
}
if (config.branch.toLowerCase().includes("stable")) {
if (!this.params.updateWarning) return;
const res = await fetch("https://registry.npmjs.org/touchguild/latest");
const json = await res.json() as jsonRes;

Expand All @@ -213,6 +215,7 @@ export class Client extends TypedEmitter<ClientEvents> {

if (config.branch.toLowerCase().includes("development")) {
console.log("TouchGuild Development Build (v" + config.version + ")");
if (!this.params.updateWarning) return;
const res = await fetch("https://registry.npmjs.org/touchguild");
const json = await res.json() as { time: Record<string, string>; };
if (Object.keys(json.time)[Object.keys(json.time).length - 1] !== config.version)
Expand Down
6 changes: 6 additions & 0 deletions lib/types/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ export interface ClientOptions {
*/
connectionMessage?: boolean;

/**
* This boolean is used to enable or disable the update warning you receive when your version of TouchGuild
* is no longer the latest anymore.
*/
updateWarning?: boolean;

/**
* If true, will wait for caching before emitting the event.
*
Expand Down

0 comments on commit 7ac07dd

Please sign in to comment.