Skip to content

Commit

Permalink
jsdoc fix
Browse files Browse the repository at this point in the history
  • Loading branch information
twlite committed Jul 16, 2022
1 parent efc9acc commit 755f521
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 3 deletions.
1 change: 1 addition & 0 deletions index.js
Expand Up @@ -26,6 +26,7 @@ module.exports = {
Spotify: require("./src/Spotify"),
Welcomer: require("./src/Welcomer"),
Leaver: require("./src/Leaver"),
Greeting: require("./src/base/GreetingsCard"),
CaptchaGen: load("captcha-canvas") ? load("captcha-canvas").CaptchaGenerator : null,
FortniteShop: load("discord-canvas") ? load("discord-canvas").FortniteShop : null,
FortniteStats: load("discord-canvas") ? load("discord-canvas").FortniteStats : null,
Expand Down
2 changes: 1 addition & 1 deletion src/Canvacord.js
Expand Up @@ -1322,7 +1322,7 @@ class Canvacord {

/**
* Canvacord assets
* @e {CanvacordAssets}
* @type {CanvacordAssets}
* @private
*/
static get assets() {
Expand Down
61 changes: 59 additions & 2 deletions src/base/GreetingsCard.js
Expand Up @@ -21,8 +21,11 @@ const applyText = (canvas, text, defaultFontSize, width, font) => {
return ctx.font;
}

module.exports = class Greeting {
class Greeting {

/**
* The base greetings class from discord-canvas
*/
constructor() {
this.username = "Clyde";
this.guildName = "ServerName";
Expand All @@ -46,54 +49,106 @@ module.exports = class Greeting {
this.colorBackground = "#000000";
}

/**
* Set avatar
* @param {string|Buffer} value The avatar
* @returns {Greeting}
*/
setAvatar(value) {
this.avatar = value;
return this;
}

/**
* Sets discriminator
* @param {string} value the discriminator
* @returns {Greeting}
*/
setDiscriminator(value) {
this.discriminator = value;
return this;
}

/**
* Set username
* @param {string} value The username
* @returns {Greeting}
*/
setUsername(value) {
this.username = value;
return this;
}

/**
* Set guild name
* @param {string} value The guild name
* @returns {Greeting}
*/
setGuildName(value) {
this.guildName = value;
return this;
}

/**
* Sets member count
* @param {number} value The member count
* @returns {Greeting}
*/
setMemberCount(value) {
this.memberCount = value;
return this;
}

/**
* Set background image
* @param {string|Buffer} value The background image
* @returns {Greeting}
*/
setBackground(value) {
this.backgroundImage = value;
return this;
}

/**
* Sets color
* @param {string} variable The variable to set the color at
* @param {string} value The color
* @returns {Greeting}
*/
setColor(variable, value) {
const formattedVariable = formatVariable("color", variable);
if (this[formattedVariable]) this[formattedVariable] = value;
return this;
}

/**
* Sets text
* @param {string} variable The variable to set the text at
* @param {string} value The text
* @returns {Greeting}
*/
setText(variable, value) {
const formattedVariable = formatVariable("text", variable);
if (this[formattedVariable]) this[formattedVariable] = value;
return this;
}

/**
* Sets opacity
* @param {string} variable Sets the opacity of the given variable
* @param {number} value The opacity to set
* @returns {Greeting}
*/
setOpacity(variable, value) {
const formattedVariable = formatVariable("opacity", variable);
if (this[formattedVariable]) this[formattedVariable] = value;
return this;
}

/**
* Builds the image
* @returns {Promise<Buffer>}
*/
async toAttachment() {
if (!this.avatar) throw new Error("avatar is required");
// Create canvas
Expand Down Expand Up @@ -173,4 +228,6 @@ module.exports = class Greeting {

return canvas;
}
};
};

module.exports = Greeting;

0 comments on commit 755f521

Please sign in to comment.