Skip to content

Commit

Permalink
fix: specify int for some number types
Browse files Browse the repository at this point in the history
  • Loading branch information
0t4u committed Oct 29, 2024
1 parent e6d19be commit 07cff56
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
12 changes: 6 additions & 6 deletions src/guild/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const Band = z.object({
*
* 14 = 16000 Hz
*/
band: z.number().min(0).max(14),
band: z.number().int().min(0).max(14),
/**
* Multiplier for each band. Valid values range from -0.25 to 1.00,
* where -0.25 means the given band is completely muted,
Expand Down Expand Up @@ -385,7 +385,7 @@ export const TrackStuckEvent = PlayerEvent.extend({
/**
* Threshold in milliseconds that was exceeded
*/
thresholdMs: z.number()
thresholdMs: z.number().int()
});

export type TrackStuckEvent = z.TypeOf<typeof TrackStuckEvent>;
Expand Down Expand Up @@ -436,7 +436,7 @@ export const WebSocketClosedEvent = PlayerEvent.extend({
* Discord close event code
* @see https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-close-event-codes
*/
code: z.number(),
code: z.number().int(),
/**
* Whether the connection was closed by Discord
*/
Expand All @@ -461,15 +461,15 @@ export const PlayerState = z.object({
/**
* The position of the track in milliseconds
*/
position: z.number(),
position: z.number().int().min(0),
/**
* Unix timestamp in milliseconds
*/
time: z.number(),
time: z.number().int().min(0),
/**
* The ping of the node to the Discord voice server in milliseconds (-1 if not connected)
*/
ping: z.number()
ping: z.number().int().min(-1)
});

export type PlayerState = z.TypeOf<typeof PlayerState>;
Expand Down
30 changes: 15 additions & 15 deletions src/node/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@ export const NodeMemory = z.object({
* Reservable memory in bytes
* @see https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Runtime.html#maxMemory()
*/
reservable: z.number(),
reservable: z.number().int().min(0),
/**
* Used memory in bytes
*
* totalMemory() - freeMemory()
*/
used: z.number(),
used: z.number().int().min(0),
/**
* Free memory in bytes
* @see https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Runtime.html#freeMemory()
*/
free: z.number(),
free: z.number().int().min(0),
/**
* Allocated memory in bytes
* @see https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Runtime.html#totalMemory()
*/
allocated: z.number()
allocated: z.number().int().min(0)
});

export type NodeMemory = z.TypeOf<typeof NodeMemory>;
Expand All @@ -73,19 +73,19 @@ export const NodeFrameStats = z.object({
/**
* Number of frames sent to Discord
*/
sent: z.number(),
sent: z.number().int(),
/**
* Difference between number of sent frames and expected number of frames
*
* Expected amount of frames is 3000 (1 frame every 20 milliseconds)
*
* If negative, too many frames were sent, if positive, not enough frames were sent
*/
deficit: z.number(),
deficit: z.number().int(),
/**
* Number of frames nulled
*/
nulled: z.number()
nulled: z.number().int()
});

export type NodeFrameStats = z.TypeOf<typeof NodeFrameStats>;
Expand Down Expand Up @@ -127,15 +127,15 @@ export const Stats = z.object({
/**
* Number of players connected to node
*/
players: z.number(),
players: z.number().int().min(0),
/**
* Number of players playing a track
*/
playingPlayers: z.number(),
playingPlayers: z.number().int().min(0),
/**
* Node uptime in milliseconds
*/
uptime: z.number(),
uptime: z.number().int().min(0),
/**
* Memory statistics
* @see {@link NodeMemory} representation in Shoukaku
Expand Down Expand Up @@ -171,15 +171,15 @@ export const NodeInfoVersion = z.object({
/**
* Major version
*/
major: z.number(),
major: z.number().int(),
/**
* Minor version
*/
minor: z.number(),
minor: z.number().int(),
/**
* Patch version
*/
patch: z.number(),
patch: z.number().int(),
/**
* Prerelease version
*/
Expand Down Expand Up @@ -209,7 +209,7 @@ export const NodeInfoGit = z.object({
/**
* UNIX timestamp in miliseconds when Git commit was created
*/
commitTime: z.number()
commitTime: z.number().int().min(0)
});

export type NodeInfoGit = z.TypeOf<typeof NodeInfoGit>;
Expand Down Expand Up @@ -247,7 +247,7 @@ export const NodeInfo = z.object({
/**
* UNIX timestamp in miliseconds when Lavalink JAR was built
*/
buildTime: z.number(),
buildTime: z.number().int().min(0),
/**
* Lavalink Git information
* @see {@link NodeInfoGit} representation in Shoukaku
Expand Down
14 changes: 7 additions & 7 deletions src/node/Rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ export const Track = z.object({
/**
* Track length in milliseconds
*/
length: z.number().int(),
length: z.number().int().min(0),
/**
* Whether the track is a livestream
*/
isStream: z.boolean(),
/**
* Current playback time in milliseconds
*/
position: z.number().int(),
position: z.number().int().min(0),
/**
* Track title
*/
Expand Down Expand Up @@ -155,7 +155,7 @@ export const Playlist = z.object({
/**
* The selected track of the playlist (-1 if no track is selected)
*/
selectedTrack: z.number().int()
selectedTrack: z.number().int().min(-1)
}),
/**
* Additional track info provided by plugins
Expand Down Expand Up @@ -393,7 +393,7 @@ export const FailingAddress = z.object({
/**
* UNIX timestamp when the IP address failed
*/
failingTimestamp: z.number().int(),
failingTimestamp: z.number().int().min(0),
/**
* Time when the IP address failed as a pretty string
* @see https://docs.oracle.com/javase/8/docs/api/java/util/Date.html#toString--
Expand Down Expand Up @@ -719,11 +719,11 @@ export const UpdatePlayerOptions = z.object({
/**
* Track position in milliseconds
*/
position: z.number().int().optional(),
position: z.number().int().min(0).optional(),
/**
* The track end time in milliseconds (must be > 0). null resets this if it was set previously
*/
endTime: z.number().int().nonnegative().nullable().optional(),
endTime: z.number().int().min(0).nullable().optional(),
/**
* The player volume, in percentage, from 0 to 1000
*/
Expand Down Expand Up @@ -783,7 +783,7 @@ export const SessionInfo = z.object({
/**
* The timeout in seconds (default is 60s)
*/
timeout: z.number().int()
timeout: z.number().int().min(0)
});

export type SessionInfo = z.TypeOf<typeof SessionInfo>;
Expand Down

0 comments on commit 07cff56

Please sign in to comment.