diff --git a/index.js b/index.js index 9ee2968d..a7d60408 100644 --- a/index.js +++ b/index.js @@ -22,6 +22,7 @@ function load(moduleName) { module.exports = { Canvas: Canvacord, + Canvacord, ConvolutionMatrix: Canvacord.CONVOLUTION_MATRIX, Rank: require("./src/Rank"), Spotify: require("./src/Spotify"), diff --git a/package.json b/package.json index 5bee540c..48342e7d 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,16 @@ { "name": "canvacord", - "version": "5.2.1", + "version": "5.2.2", "description": "Powerful image manipulation package for beginners.", "main": "index.js", + "types": "typings/index.d.ts", + "files": [ + "libs", + "plugins", + "src", + "index.js", + "typings" + ], "scripts": { "docs": "docgen --source src --custom docs/index.yml --output docs/docs.json", "docs:test": "docgen --source src --custom docs/index.yml", @@ -40,17 +48,17 @@ }, "homepage": "https://canvacord.js.org", "dependencies": { - "@canvacord/assets": "^1.0.2", + "@canvacord/assets": "^2.0.5", "@canvacord/emoji-parser": "^1.0.1", - "canvas": "^2.7.0", + "canvas": "^2.8.0", "gifencoder": "^2.0.1", "moment": "^2.29.1", "moment-duration-format": "^2.3.2" }, "devDependencies": { - "@types/node": "^14.11.2", - "captcha-canvas": "^2.2.1", - "discord-canvas": "github:snowflake107/discord-canvas", - "discord.js-docgen": "github:discordjs/docgen" + "@discordjs/docgen": "discordjs/docgen", + "@types/node": "^16.4.7", + "captcha-canvas": "^2.3.1", + "discord-canvas": "github:snowflake107/discord-canvas" } } diff --git a/typings/index.d.ts b/typings/index.d.ts new file mode 100644 index 00000000..c5746525 --- /dev/null +++ b/typings/index.d.ts @@ -0,0 +1,984 @@ +// generated by JSDOC + +declare module "canvacord" { + import Canvas from 'canvas' + /** + *
⚠ You may not instantiate Canvacord class! ⚠
+ * @example + * const Canvacord = require("canvacord"); + + Canvacord.Canvas.trigger("./image.png") + .then(triggered => { + Canvacord.write(triggered, "triggered.gif"); + }) + */ + export class Canvacord { + /** + *This method can be used to apply Triggered effect on image.
+ * @param image -Image to trigger
+ */ + static trigger(image: string | Buffer): PromiseInverts color of the image
+ * @param image -Img to invert
+ */ + static invert(image: string | Buffer): PromiseApply sepia wash on img
+ * @param image -Img
+ */ + static sepia(image: string | Buffer): PromiseGreyscale effect over image
+ * @param image -Img
+ */ + static greyscale(image: string | Buffer): PromiseEdit image brightness
+ * @param image -Img
+ * @param amount -Brightness amount
+ */ + static brightness(image: string | Buffer, amount: number): PromiseEdit image darkness
+ * @param image -Img
+ * @param amount -Darkness amount
+ */ + static darkness(image: string | Buffer, amount: number): PromiseImage threshold
+ * @param img -Image
+ * @param amount -Threshold amount
+ */ + static threshold(img: string | Buffer, amount: number): PromiseImage Convolution
+ * @param img -Image
+ * @param matrix -Convolution matrix
+ * @param opaque -If convolution should be opaque
+ */ + static convolute(img: string | Buffer, matrix: number[], opaque: boolean): PromiseCreates Progress bar
+ * @param track -Progressbar track options
+ * @param [track.x] -The x-axis
+ * @param [track.y] -The y-axis
+ * @param [track.width] -Progressbar track width
+ * @param [track.height] -Progressbar track height
+ * @param [track.color] -Progressbar track color
+ * @param [track.stroke] -Use stroke for track
+ * @param [track.lineWidth] -This param will be used if track.stroke
is set to true
Progressbar options
+ * @param [bar.width] -Progressbar width
+ * @param [bar.color] -Progressbar color
+ */ + static createProgressBar(track: { + x?: number; + y?: number; + width?: number; + height?: number; + color?: string; + stroke?: boolean; + lineWidth?: number; + }, bar: { + width?: number; + color?: string; + }): Buffer; + /** + *Blur an image
+ * @param image -Image to blur
+ */ + static blur(image: string | Buffer): PromisePixelate
+ * @param image -Image to pixelate
+ * @param pixels -Pixels
+ */ + static pixelate(image: string | Buffer, pixels?: number): PromiseSharpen an image
+ * @param image -Image to sharpen
+ * @param lvl -sharpness intensity
+ */ + static sharpen(image: string | Buffer, lvl?: number): PromiseApplies burn effect on an image
+ * @param image -Image source
+ * @param lvl -intensity
+ */ + static burn(image: string | Buffer, lvl?: number): PromiseHTML5 color to image
+ * @param color -HTML5 color
+ * @param displayHex -If it should display hex
+ * @param height -Image height
+ * @param width -Image width
+ */ + static color(color?: string, displayHex?: boolean, height?: number, width?: number): Buffer; + /** + *Creates circular image
+ * @param image -Image source
+ */ + static circle(image: string | Buffer): PromiseCreates a rectangle
+ * @param x -x-axis
+ * @param y -y-axis
+ * @param width -width
+ * @param height -height
+ * @param color -color
+ * @param stroke -If it should stroke
+ * @param lineWidth -line width
+ */ + static rectangle(x: number, y: number, width: number, height: number, color: string, stroke: boolean, lineWidth: number): Buffer; + /** + *Fuse two images
+ * @param image1 -First image
+ * @param image2 -Second image
+ */ + static fuse(image1: string | Buffer, image2: string | Buffer): PromiseResize an image
+ * @param image -Image source
+ * @param width -width
+ * @param height -height
+ */ + static resize(image: string | Buffer, width: number, height: number): PromiseKiss each other ( ͡° ͜ʖ ͡°)
+ * @param image1 -First image
+ * @param image2 -Second image
+ */ + static kiss(image1: string | Buffer, image2: string | Buffer): PromiseSpank someone ( ͡° ͜ʖ ͡°)
+ * @param image1 -First image
+ * @param image2 -Second image
+ */ + static spank(image1: string | Buffer, image2: string | Buffer): PromiseLoads font
+ * @param fontArray -Font array
+ */ + static registerFonts(fontArray: any[]): PromiseSlap someone ( ͡° ͜ʖ ͡°)
+ * @param image1 -First image
+ * @param image2 -Second image
+ */ + static slap(image1: string | Buffer, image2: string | Buffer): PromiseOh this? This is beautiful!
+ * @param image -Source image
+ */ + static beautiful(image: string | Buffer): Promisefacepalm
+ * @param image -image
+ */ + static facepalm(image: string | Buffer): PromiseRainbow ( ͡° ͜ʖ ͡°)
+ * @param image -Image source
+ */ + static rainbow(image: string | Buffer): Promise"F" in the chat
+ * @param image -image source
+ */ + static rip(image: string | Buffer): PromiseTrash?
+ * @param image -Image source
+ */ + static trash(image: string | Buffer): PromiseWorse than hitler
+ * @param image -Source image
+ */ + static hitler(image: string | Buffer): PromiseUpdates image color
+ * @param image -Image source
+ * @param color -HTML5 color
+ */ + static colorfy(image: string | Buffer, color: string): Promisewhoosh
+ * @param image -Image source
+ */ + static jokeOverHead(image: string | Buffer): PromiseDistracted boyfriend
+ * @param image1 -Face for the girl in red color
+ * @param image2 -Face for the boy
+ * @param image3 -Face for the other girl [optional]
+ */ + static distracted(image1: string | Buffer, image2: string | Buffer, image3: string | Buffer): PromiseNo, it doesn't affect my baby.
+ * @param image -Source image
+ */ + static affect(image: string | Buffer): PromiseJail
+ * @param image -Source image
+ * @param greyscale -If it should greyscale image
+ */ + static jail(image: string | Buffer, greyscale: boolean): Promisebed
+ * @param image1 -First image
+ * @param image2 -Second image
+ */ + static bed(image1: string | Buffer, image2: string | Buffer): PromiseDelete
+ * @param image -Source image
+ * @param dark -If image should be in dark mode
+ */ + static delete(image: string | Buffer, dark: boolean): PromiseTicTacToe
+ * @param fill -TicTacToe params
+ * @param [fill.a1] -a1 value
+ * @param [fill.b1] -b1 value
+ * @param [fill.c1] -c1 value
+ * @param [fill.a2] -a2 value
+ * @param [fill.b2] -b2 value
+ * @param [fill.c2] -c2 value
+ * @param [fill.a3] -a3 value
+ * @param [fill.b3] -b3 value
+ * @param [fill.c3] -c3 value
+ * @param color -Color params
+ * @param [color.bg] -Background clolor
+ * @param [color.bar] -TicTacToe bar color
+ * @param [color.x] -Color of X
+ * @param [color.o] -Color of O
+ */ + static tictactoe(fill: { + a1?: "X" | "O"; + b1?: "X" | "O"; + c1?: "X" | "O"; + a2?: "X" | "O"; + b2?: "X" | "O"; + c2?: "X" | "O"; + a3?: "X" | "O"; + b3?: "X" | "O"; + c3?: "X" | "O"; + }, color: { + bg?: string; + bar?: string; + x?: string; + o?: string; + }): Buffer; + /** + *Opinion
+ * @param avatar -Image
+ * @param msg -Message
+ */ + static opinion(avatar: string | Buffer, msg: string): PromiseCreates Gradient
+ * @param colorFrom -Starting color
+ * @param colorTo -Ending color
+ * @param width -Image width
+ * @param height -Image height
+ */ + static gradient(colorFrom: string, colorTo: string, width: number, height: number): Buffer; + /** + *Oh no! It's Stupid.
+ * @param message -Message
+ */ + static ohno(message: string): PromiseChange my mind (taken from jgoralcz/image-microservice)
+ * @param text -Text
+ */ + static changemymind(text: string): PromiseClyde
+ * @param message -Message
+ */ + static clyde(message: string): PromiseFake Quote
+ * @param options -Options
+ * @param [options.image] -Image
+ * @param [options.message] -Message
+ * @param [options.username] -Username
+ * @param [options.color] -Color
+ */ + static quote(options: { + image?: Buffer | string; + message?: string; + username?: string; + color?: string; + }): PromisePornHub Comment
+ * @param options -Options
+ * @param [options.username] -Username
+ * @param [options.message] -Comment
+ * @param [options.image] -Image
+ */ + static phub(options: { + username?: string; + message?: string; + image?: string | Buffer; + }): PromiseWanted
+ * @param image -Source image
+ */ + static wanted(image: string | Buffer): PromiseWasted
+ * @param image -Source image
+ */ + static wasted(image: string | Buffer): PromiseYouTube comment
+ * @param ops -YouTube comment options
+ * @param [ops.username] -Comment author username
+ * @param [ops.content] -The comment
+ * @param [ops.avatar] -Avatar source
+ * @param [ops.dark = false] -Dark mode?
+ */ + static youtube(ops: { + username?: string; + content?: string; + avatar?: string | Buffer; + dark?: boolean; + }): PromiseOh Shit!
+ * @param image -Source image
+ */ + static shit(image: string | Buffer): PromiseWrites the data as file
+ * @param data -data to write
+ * @param name -file name
+ */ + static write(data: Buffer, name: string): void; + /** + *Returns default icon of a discord server
+ * @param name -Guild name
+ * @param size -Icon size. Valid: 16
, 32
, 64
, 128
, 256
, 512
, 1024
, 2048
& 4096
Discord Reply Clone
+ * @example + * const img = "https://cdn.discordapp.com/embed/avatars/0.png"; + const img2 = "https://cdn.discordapp.com/embed/avatars/4.png"; + canvacord.Canvas.reply({ + avatar1: img, + avatar2: img2, + user1: "Maximus", + user2: "Snowflake", + hex1: "#FF3300", + hex2: "#7289da", + mainText: "kok", + replyText: "Pog" + }) + .then(img => canvacord.write(img, "reply.png")); + * @param options -Options
+ * @param [options.avatar1] -Avatar of the person who replied
+ * @param [options.avatar2] -Avatar of the other person
+ * @param [options.user1] -Username of the person who replied
+ * @param [options.user2] -Username of the other person
+ * @param [options.hex1] -Hex color of the person who replied
+ * @param [options.hex2] -Hex color of the other person
+ * @param [options.mainText] -The message
+ * @param [options.replyText] -The reply message
+ */ + static reply(options: { + avatar1?: string | Buffer; + avatar2?: string | Buffer; + user1?: string; + user2?: string; + hex1?: string; + hex2?: string; + mainText?: string; + replyText?: string; + }): PromiseCanvacord method used to wait
.
Number of milliseconds to wait
+ */ + static __wait(dur: number): PromiseMatrix data for Canvacord.convolute()
+ */ + static CONVOLUTION_MATRIX: ConvolutionMatrix; + /** + *Canvacord utils
+ */ + static Util: Util; + } + + /** + *Canvacord convolution matrix
+ * @property EDGES -Edges Matrix
+ * @property BLUR -Blur Matrix
+ * @property SHARPEN -Sharpen Matrix
+ * @property BURN -Burn Matrix
+ */ + export type ConvolutionMatrix = { + EDGES: number[]; + BLUR: number[]; + SHARPEN: number[]; + BURN: number[]; + }; + + /** + *Creates spotify presence card
+ * @example + * const card = new canvacord.Spotify() + * .setAuthor("Indila") + * .setAlbum("Mini World") + * .setStartTimestamp(Date.now() - 10000) + * .setEndTimestamp(Date.now() + 50000) + * .setImage("https://is5-ssl.mzstatic.com/image/thumb/Features111/v4/a4/89/a1/a489a1cb-4543-6861-a276-4470d41d6a90/mzl.zcdmhnlk.jpg/800x800bb.jpeg") + * .setTitle("S.O.S"); + * + * card.build() + * .then(data => { + * canvacord.write(data, "./images/spotify.png"); + * }); + */ + export class Spotify { + /** + *Song title
+ */ + title: string; + /** + *Thumbnail
+ */ + image: string | Buffer | Canvas.Image; + /** + *Song artist
+ */ + artist: string; + /** + *Spotify album name
+ */ + album: string; + /** + *Discord presence started timestamp
+ */ + start: number; + /** + *Discord presence ending timestamp
+ */ + end: number; + /** + *Background
+ */ + background: SpotifyDataBG; + /** + *Progressbar details
+ */ + progressBar: SpotifyProgressBarData; + /** + *Set progressbar details
+ * @param type -Progressbar type
+ * @param color -Color to set
+ */ + setProgressBar(type: "TRACK" | "BAR", color: string): Spotify; + /** + *Set title
+ * @param title -Title to set
+ */ + setTitle(title: string): Spotify; + /** + *Set image
+ * @param source -Image source
+ */ + setImage(source: string | Buffer | Canvas.Image): Spotify; + /** + *Set artist name
+ * @param name -Artist name
+ */ + setAuthor(name: string): Spotify; + /** + *Set album name
+ * @param name -Album name
+ */ + setAlbum(name: string): Spotify; + /** + *Set start timestamp
+ * @param time -Timestamp
+ */ + setStartTimestamp(time: Date | number): Spotify; + /** + *Set end timestamp
+ * @param time -Timestamp
+ */ + setEndTimestamp(time: Date | number): Spotify; + /** + *Set background
+ * @param type -Background type
+ * @param data -Background data
+ */ + setBackground(type?: "COLOR" | "IMAGE", data?: string | Buffer | Canvas.Image): Spotify; + /** + *This function converts raw data into spotify presence card.
+ */ + build(): PromiseBackground type
+ * @property data -Background data
+ */ + export type SpotifyDataBG = { + type: number; + data: string | Buffer; + }; + + /** + * @property bgColor -Progressbar bg color
+ * @property color -Progressbar bg color
+ */ + export type SpotifyProgressBarData = { + bgColor: string; + color: string; + }; + + /** + *Welcome image builder
+ * @example + * const card = new canvacord.Welcomer() + * .setUsername("Snowflake") + * .setDiscriminator("0007") + * .setGuildName("Snowflake Studio"); + * + * card.build() + * .then(data => { + * canvacord.write(data, "welcomer.png"); + * }) + */ + export class Welcomer { + constructor(); + /** + *Title created with Canvacord
+ */ + textTitle: string; + /** + *Text message created with Canvacord
+ */ + textMessage: string; + /** + *Title color created with canvacord
+ */ + colorTitle: string; + /** + *Set color
+ * @param color -HTML5 color code
+ */ + setColor(id: "title" | "title-border" | "avatar" | "username" | "username-box" | "hashtag" | "discriminator" | "discriminator-box" | "message" | "message-box" | "member-count" | "background" | "border", color: string): Welcomer; + /** + *Ser member count
+ * @param memberCount -Guild member count
+ */ + setMemberCount(memberCount?: number | string): Welcomer; + /** + *Builds welcome image
+ */ + build(): PromiseLeaver image builder
+ * @example + * const card = new canvacord.Leaver() + * .setUsername("Snowflake") + * .setDiscriminator("0007") + * .setGuildName("Snowflake Studio"); + * + * card.build() + * .then(data => { + * canvacord.write(data, "leaver.png"); + * }) + */ + export class Leaver { + constructor(); + /** + *Title created with Canvacord
+ */ + textTitle: string; + /** + *Text message created with Canvacord
+ */ + textMessage: string; + /** + *Title color created with canvacord
+ */ + colorTitle: string; + /** + *Set color
+ * @param color -HTML5 color code
+ */ + setColor(id: "title" | "title-border" | "avatar" | "username" | "username-box" | "hashtag" | "discriminator" | "discriminator-box" | "message" | "message-box" | "member-count" | "background" | "border", color: string): Leaver; + /** + *Ser member count
+ * @param memberCount -Guild member count
+ */ + setMemberCount(memberCount?: number | string): Leaver; + /** + *Builds welcome image
+ */ + build(): PromiseCircle plugin
+ * @property convolute -Convolute plugin
+ * @property rectangle -Rectangle plugin
+ * @property round -Round plugin
+ * @property abbrev -Abbrev plugin
+ * @property renderEmoji -Emoji rendering plugin
+ */ + export type Plugins = { + circle: (...params: any[]) => any; + convolute: (...params: any[]) => any; + rectangle: (...params: any[]) => any; + round: (...params: any[]) => any; + abbrev: (...params: any[]) => any; + renderEmoji: (...params: any[]) => any; + }; + + /** + * @property width -Rank card width
+ * @property height -Rank card height
+ * @property background -Rank card background data
+ * @property [background.type = "color"] -Background type
+ * @property [background.image = "#23272A"] -Background image (or color)
+ * @property progressBar -Progressbar data
+ * @property [progressBar.rounded = true] -If the progressbar should be rounded
+ * @property [progressBar.x = 275.5] -Progressbar X
+ * @property [progressBar.y = 183.75] -Progressbar Y
+ * @property [progressBar.height = 37.5] -Progressbar height
+ * @property [progressBar.width = 596.5] -Progressbar width
+ * @property [progressBar.track] -Progressbar track
+ * @property [progressBar.track.color = "#484b4E"] -Progressbar track color
+ * @property [progressBar.bar] -Progressbar bar data
+ * @property [progressBar.bar.type = "color"] -Progressbar bar type
+ * @property [progressBar.bar.color = "#FFFFFF"] -Progressbar bar color
+ * @property overlay -Progressbar overlay
+ * @property [overlay.display = true] -If it should display overlay
+ * @property [overlay.level = 0.5] -Overlay opacity level
+ * @property [overlay.color = "#333640"] -Overlay bg color
+ * @property avatar -Rank card avatar data
+ * @property [avatar.source = null] -Avatar source
+ * @property [avatar.x = 70] -X
+ * @property [avatar.y = 50] -Y
+ * @property [avatar.height = 180] -height
+ * @property [avatar.width = 180] -width
+ * @property status -Rank card status
+ * @property [status.width = 5] -Status width
+ * @property [status.type] -Status type
+ * @property [status.color = "#43B581"] -Status color
+ * @property [status.circle = false] -Circualr status?
+ * @property rank -Rank card rank data
+ * @property [rank.display = true] -If it should display rank
+ * @property [rank.data = 1] -The Rank
+ * @property [rank.textColor = "#FFFFFF"] -Rank text color
+ * @property [rank.color = "#F3F3F3"] -Rank color
+ * @property [rank.displayText = "RANK"] -Rank display text
+ * @property level -Rank card level data
+ * @property [level.display = true] -If it should display level
+ * @property [level.data = 1] -The level
+ * @property [level.textColor = "#FFFFFF"] -level text color
+ * @property [level.color = "#F3F3F3"] -level color
+ * @property [level.displayText = "LEVEL"] -level display text
+ * @property currentXP -Rank card current xp
+ * @property [currentXP.data = 0] -Current xp
+ * @property [currentXP.color = "#FFFFFF"] -Rank card current xp color
+ * @property requiredXP -Rank card required xp
+ * @property [requiredXP.data = 0] -required xp
+ * @property [requiredXP.color = "#FFFFFF"] -Rank card required xp color
+ * @property discriminator -Rank card discriminator
+ * @property [discriminator.discrim = null] -The discriminator
+ * @property [discriminator.color = "rgba(255, 255, 255, 0.4)"] -Rank card discriminator color
+ * @property username -Username Data
+ * @property [username.name = null] -Rank card username
+ * @property [username.color = "#FFFFFF"] -Rank card username color
+ * @property [renderEmojis = false] -If it should render emojis
+ */ + export type CanvacordRankData = { + width: number; + height: number; + background: { + type?: "image" | "color"; + image?: string | Buffer; + }; + progressBar: { + rounded?: boolean; + x?: number; + y?: number; + height?: number; + width?: number; + track?: { + color?: string; + }; + bar?: { + type?: "color" | "gradient"; + color?: string | string[]; + }; + }; + overlay: { + display?: boolean; + level?: number; + color?: string; + }; + avatar: { + source?: string | Buffer; + x?: number; + y?: number; + height?: number; + width?: number; + }; + status: { + width?: number; + type?: "online" | "dnd" | "idle" | "offline" | "streaming"; + color?: string; + circle?: boolean; + }; + rank: { + display?: boolean; + data?: number; + textColor?: string; + color?: string; + displayText?: string; + }; + level: { + display?: boolean; + data?: number; + textColor?: string; + color?: string; + displayText?: string; + }; + currentXP: { + data?: number; + color?: string; + }; + requiredXP: { + data?: number; + color?: string; + }; + discriminator: { + discrim?: number | string; + color?: string; + }; + username: { + name?: string; + color?: string; + }; + renderEmojis?: boolean; + }; + + /** + *Creates Rank card
+ * @example + * const rank = new canvacord.Rank() + * .setAvatar(img) + * .setCurrentXP(203) + * .setRequiredXP(500) + * .setStatus("dnd") + * .setProgressBar(["#FF0000", "#0000FF"], "GRADIENT") + * .setUsername("Snowflake") + * .setDiscriminator("0007"); + * + * rank.build() + * .then(data => { + * canvacord.write(data, "RankCard.png"); + * }) + */ + export class Rank { + constructor(); + /** + *Rank card data
+ */ + data: CanvacordRankData; + /** + *Loads font
+ * @param fontArray -Font array
+ */ + registerFonts(fontArray: any[]): Rank; + /** + *If it should render username with emojis (if any)
+ * @param [apply = false] -Set it to true
to render emojis.
Set username
+ * @param name -Username
+ * @param color -Username color
+ */ + setUsername(name: string, color?: string): Rank; + /** + *Set discriminator
+ * @param discriminator -User discriminator
+ * @param color -Discriminator color
+ */ + setDiscriminator(discriminator: string | number, color?: string): Rank; + /** + *Set progressbar style
+ * @param color -Progressbar Color
+ * @param [fillType = COLOR] -Progressbar type
+ * @param [rounded = true] -If progressbar should have rounded edges
+ */ + setProgressBar(color: string | string[], fillType?: "COLOR" | "GRADIENT", rounded?: boolean): Rank; + /** + *Set progressbar track
+ * @param color -Track color
+ */ + setProgressBarTrack(color: string): Rank; + /** + *Set card overlay
+ * @param color -Overlay color
+ * @param [level = 0.5] -Opacity level
+ * @param [display = true] -IF it should display overlay
+ */ + setOverlay(color: string, level?: number, display?: boolean): Rank; + /** + *Set required xp
+ * @param data -Required xp
+ * @param color -Color
+ */ + setRequiredXP(data: number, color?: string): Rank; + /** + *Set current xp
+ * @param data -Current xp
+ * @param color -Color
+ */ + setCurrentXP(data: number, color?: string): Rank; + /** + *Set Rank
+ * @param data -Current Rank
+ * @param text -Display text
+ * @param [display = true] -If it should display rank
+ */ + setRank(data: number, text?: string, display?: boolean): Rank; + /** + *Set rank display color
+ * @param text -text color
+ * @param number -Number color
+ */ + setRankColor(text?: string, number?: string): Rank; + /** + *Set level color
+ * @param text -text color
+ * @param number -number color
+ */ + setLevelColor(text?: string, number?: string): Rank; + /** + *Set Level
+ * @param data -Current Level
+ * @param text -Display text
+ * @param [display = true] -If it should display level
+ */ + setLevel(data: number, text?: string, display?: boolean): Rank; + /** + *Set custom status color
+ * @param color -Color to set
+ */ + setCustomStatusColor(color: string): Rank; + /** + *Set status
+ * @param status -User status
+ * @param circle -If status icon should be circular.
+ * @param width -Status width
+ */ + setStatus(status: "online" | "idle" | "dnd" | "offline" | "streaming", circle: boolean, width?: number | boolean): Rank; + /** + *Set background image/color
+ * @param type -Background type
+ * @param [data] -Background color or image
+ */ + setBackground(type: "COLOR" | "IMAGE", data?: string | Buffer): Rank; + /** + *User avatar
+ * @param data -Avatar data
+ */ + setAvatar(data: string | Buffer): Rank; + /** + *Builds rank card
+ * @param ops -Fonts
+ * @param [ops.fontX = "Manrope"] -Bold font family
+ * @param [ops.fontY = "Manrope"] -Regular font family
+ */ + build(ops: { + fontX?: string; + fontY?: string; + }): PromiseCanvacord Util
+ */ + export class Util { + constructor(); + /** + *Validates hex
+ * @param hex -Hex code to validate
+ */ + static validateHex(hex: string): boolean; + /** + *Converts regular timestamp to discord like time
+ * @param time -Timestamp to convert
+ */ + static discordTime(time: Date | number): string; + /** + *Formats time
+ * @param time -Time to format
+ */ + static formatTime(time: number): string; + /** + *Shorten text.
+ * @param text -Text to shorten
+ * @param len -Max Length
+ */ + static shorten(text: string, len: number): string; + /** + *Converts numbers into units like 1K
, 1M
, 1B
etc.
Renders text with emoji
+ * @param ctx -CanvasRenderingContext2D
+ * @param msg -Message
+ * @param x -X
+ * @param y -Y
+ */ + static renderEmoji(ctx: CanvasRenderingContext2D, msg: string, x: number, y: number): PromiseReturns formatted hex code
+ * @param hex -Hex code to format
+ * @param alt -Alt color
+ */ + static formatHex(hex: string, alt?: string): string; + /** + *Inverts hex color
+ * @param hex -Hex color code to invert
+ */ + static invertColor(hex: string): string; + /** + *Returns acronym
+ * @param name -Name to parse acronym
+ */ + static getAcronym(name: string): string; + /** + *Returns array of lines
+ * @param params -Params
+ * @param text -Text
+ * @param ctx -CanvasRenderingContext2D
+ * @param maxWidth -Max width
+ */ + static getLines(params: any, text: string, ctx: CanvasRenderingContext2D, maxWidth: number): string[]; + } +} \ No newline at end of file