Skip to content

Commit

Permalink
disable husky for now
Browse files Browse the repository at this point in the history
  • Loading branch information
typicalninja committed Apr 28, 2023
1 parent 4519c97 commit f7bcac4
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 29 deletions.
1 change: 0 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm prettier:write
59 changes: 34 additions & 25 deletions packages/disci/src/structures/primitives/Guild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ export class PartialGuild implements IBase {
* Fetch the guild this partial belongs to
* @param opts.witCounts when true, will return approximate member and presence counts for the guild
*/
async fetch({ withCounts }: { withCounts?: boolean} = {}) {
async fetch({ withCounts }: { withCounts?: boolean } = {}) {
const guild = await this.handler.api.get<APIGuild>(Routes.guild(this.id), {
query: withCounts ? {
'with_counts': 'true'
} : {}
query: withCounts
? {
with_counts: 'true',
}
: {},
})
return new Guild(this.handler, guild)
}
Expand All @@ -39,56 +41,56 @@ export default class Guild extends PartialGuild {
/**
* Name of this guild
*/
name: string;
name: string
/**
* Approximate Member count not always present (use Guild.fetch() with "withCounts" enabled)
*/
approximateMemberCount?: number;
approximateMemberCount?: number
/**
* Approximate Presence count not always present (use Guild.fetch() with "withCounts" enabled)
*/
approximatePresenceCount?: number;
approximatePresenceCount?: number
/**
* The description for the guild
*/
description: string | null
/**
* Enabled guild features (animated banner, news, auto moderation, etc).
* @link https://discord.com/developers/docs/resources/guild#guild-object-guild-features
*/
* Enabled guild features (animated banner, news, auto moderation, etc).
* @link https://discord.com/developers/docs/resources/guild#guild-object-guild-features
*/
features: GuildFeature[]
/**
* Icon hash for this guild's Icon
* @link https://discord.com/developers/docs/reference#image-formatting
*/
* Icon hash for this guild's Icon
* @link https://discord.com/developers/docs/reference#image-formatting
*/
iconHash: string | null
constructor(handler: InteractionHandler, apiData: APIGuild) {
super(handler, { id: apiData.id })
this.owner = new PartialUser(handler, { id: apiData.owner_id })
this.name = apiData.name;
this.name = apiData.name
this.description = apiData.description
this.features = apiData.features
this.iconHash = apiData.icon
// present only with "with_counts"
if('approximate_member_count' in apiData) {
this.approximateMemberCount = apiData.approximate_member_count
if ('approximate_member_count' in apiData) {
this.approximateMemberCount = apiData.approximate_member_count
}

if('approximate_presence_count' in apiData) {
this.approximatePresenceCount = apiData.approximate_presence_count
if ('approximate_presence_count' in apiData) {
this.approximatePresenceCount = apiData.approximate_presence_count
}
}
/**
* boolean to indicate if this guild is a verified guild or not
*/
get verified() {
return this.features.includes(GuildFeature.Verified);
return this.features.includes(GuildFeature.Verified)
}
/**
* boolean to indicate if this guild is a partnered guild or not
*/
get partnered() {
return this.features.includes(GuildFeature.Partnered);
return this.features.includes(GuildFeature.Partnered)
}
/**
* TimeStamp of when this guild was created
Expand All @@ -103,10 +105,17 @@ export default class Guild extends PartialGuild {
return new Date(this.createdTimestamp)
}
/**
* iconURL gets the current guild icon.
* @link https://discord.com/developers/docs/reference#image-formatting
*/
iconURL(opts: { size?: DiscordImageSize; format?: GuildIconFormat} = { size: 128 }) {
return this.iconHash && (`${URLS.DiscordCdn}/${CDNRoutes.guildIcon(this.id, this.iconHash, opts.format ?? (this.iconHash.startsWith('a_') ? ImageFormat.JPEG : ImageFormat.JPEG))}`)
* iconURL gets the current guild icon.
* @link https://discord.com/developers/docs/reference#image-formatting
*/
iconURL(opts: { size?: DiscordImageSize; format?: GuildIconFormat } = { size: 128 }) {
return (
this.iconHash &&
`${URLS.DiscordCdn}/${CDNRoutes.guildIcon(
this.id,
this.iconHash,
opts.format ?? (this.iconHash.startsWith('a_') ? ImageFormat.JPEG : ImageFormat.JPEG),
)}`
)
}
}
4 changes: 2 additions & 2 deletions packages/disci/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export enum DiscordVerificationHeaders {
/**
* @link https://discord.com/developers/docs/reference#image-formatting
*/
export type DiscordImageSize = 16 | 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096;
export type DiscordImageSize = 16 | 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096

export const DiscordEpoch = 14200704e5

Expand Down Expand Up @@ -60,7 +60,7 @@ export type TRespondCallback = (interaction: InteractionContext) => IResponse |

export enum URLS {
DiscordApi = 'https://discord.com/api',
DiscordCdn = 'https://cdn.discordapp.com'
DiscordCdn = 'https://cdn.discordapp.com',
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/disci/src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ export const isObject = (value: unknown) => value !== null && typeof value === '
* Detect if current runtime is node.js
* from is-node (npm)
*/
export const isNode = !!(typeof process !== 'undefined' && process.versions && process.versions.node)
export const isNode = !!(typeof process !== 'undefined' && process.versions && process.versions.node)

0 comments on commit f7bcac4

Please sign in to comment.