Skip to content

Commit

Permalink
✨ support for embedFooter.iconURL
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico105 committed Jun 12, 2021
1 parent 17f4fd2 commit 35ec38f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/custom-databases/mongoose.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const giveawaySchema = new mongoose.Schema({
inviteToParticipate: String,
timeRemaining: String,
winMessage: String,
embedFooter: String,
embedFooter: mongoose.Mixed,
noWinner: String,
winners: String,
endedAt: String,
Expand Down
10 changes: 9 additions & 1 deletion src/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Discord = require('discord.js');
* @property {string} [inviteToParticipate='React with 🎉 to participate!'] Displayed in the giveaway embed. Incite people to react to the giveaway.
* @property {string} [timeRemaining='Time remaining: **{duration}**'] Displayed below inviteToParticipate in the giveaway embed. {duration} will be replaced automatically with the time remaining.
* @property {string} [winMessage='Congratulations, {winners}! You won **{prize}**!\n{messageURL}'] Sent in the channel when the giveaway is ended.
* @property {string} [embedFooter='Powered by the discord-giveaways package'] The footer of the giveaway embed.
* @property {string|embedFooterObject} [embedFooter='Powered by the discord-giveaways package'] The footer of the giveaway embed.
* @property {string} [noWinner='Giveaway cancelled, no valid participations.'] Sent in the channel if there's no valid winner for the giveaway.
* @property {string} [winners='winner(s)'] Displayed next to the embed footer, used to display the number of winners of the giveaways.
* @property {string} [endedAt='Ended at'] Displayed next to the embed footer, used to display the giveaway end date.
Expand Down Expand Up @@ -69,6 +69,14 @@ exports.defaultGiveawayMessages = {
}
};

/**
* Embed Footer object.
* @typedef embedFooterObject
*
* @property {string} [text] The text of the footer.
* @property {string} [iconURL] The icon URL of the footer.
*/

/**
* Bonus entry object.
* @typedef BonusEntry
Expand Down
7 changes: 6 additions & 1 deletion src/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ class GiveawaysManager extends EventEmitter {
embed
.setTitle(giveaway.prize)
.setColor(lastChanceEnabled ? giveaway.lastChance.embedColor : giveaway.embedColor)
.setFooter(`${giveaway.winnerCount} ${giveaway.messages.winners}${giveaway.messages.embedFooter}`)
.setFooter(
`${giveaway.winnerCount} ${giveaway.messages.winners}${
giveaway.messages.embedFooter.text || giveaway.messages.embedFooter
}`,
giveaway.messages.embedFooter.iconURL
)
.setDescription(
(lastChanceEnabled ? giveaway.lastChance.content + '\n\n' : '') +
giveaway.messages.inviteToParticipate +
Expand Down
2 changes: 1 addition & 1 deletion typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ declare module 'discord-giveaways' {
inviteToParticipate?: string;
timeRemaining?: string;
winMessage?: string;
embedFooter?: string;
embedFooter?: string | { text: string; iconURL: string; };
noWinner?: string;
winners?: string;
endedAt?: string;
Expand Down

2 comments on commit 35ec38f

@Nico105
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we maybe use that inconURL for endEmbed and noValidPariticipationsEmbed too?

@reinacchi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

Please sign in to comment.