Skip to content

Commit

Permalink
new defaults for embedFooter and winners message
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico105 committed Aug 29, 2021
1 parent 0bbf272 commit 823dd8f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 26 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ You can also pass a `messages` parameter for `start()` function, if you want to
- **options.messages.winMessage**: the message that will be displayed to congratulate the winner(s) when the giveaway is ended. You can [send an embed instead of, or with the normal message](https://github.com/Androz2091/discord-giveaways#send-embed-as-message).
- **options.messages.embedFooter**: the message displayed at the bottom of the embeds. [Can be deactivated and iconURL can be set](https://discord-giveaways.js.org/global.html#EmbedFooterObject).
- **options.messages.noWinner**: the message that is displayed if no winner can be drawn.
- **options.messages.winners**: simply the word "winner" in your language.
- **options.messages.hostedBy**: the message to display the host of the giveaway.
- **options.messages.winners**: simply the expression "winner(s):" in your language.
- **options.messages.endedAt**: simply the words "Ended at" in your language.

For example:
Expand All @@ -454,10 +455,10 @@ client.giveawaysManager.start(interaction.channel, {
drawing: 'Drawing: {timestamp}',
inviteToParticipate: 'React with 🎉 to participate!',
winMessage: 'Congratulations, {winners}! You won **{this.prize}**!\n{this.messageURL}',
embedFooter: 'Powered by the discord-giveaways package',
embedFooter: '{this.winnerCount} winner(s) • Powered by the discord-giveaways package',
noWinner: 'Giveaway cancelled, no valid participations.',
hostedBy: 'Hosted by: {this.hostedBy}',
winners: 'winner(s)',
winners: 'Winner(s):',
endedAt: 'Ended at',
}
});
Expand Down
11 changes: 5 additions & 6 deletions src/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ const Discord = require('discord.js');
* @property {string} [giveaway='🎉🎉 **GIVEAWAY** 🎉🎉'] Displayed above the giveaway embed when the giveaway is running.
* @property {string} [giveawayEnded='🎉🎉 **GIVEAWAY ENDED** 🎉🎉'] Displayed above the giveaway embed when the giveaway has ended.
* @property {string} [inviteToParticipate='React with 🎉 to participate!'] Displayed in the giveaway embed. Invite people to react to the giveaway.
* @property {string|MessageObject} [winMessage='Congratulations, {winners}! You won **{this.prize}**!\n{this.messageURL}'] Sent in the channel when the giveaway is ended.
* @property {string|MessageObject} [winMessage='Congratulations, {winners}! You won **{this.prize}**!\n{this.messageURL}'] Sent in the channel when the giveaway is ended. "{winners}" will be replaced automatically with the mentions of the giveaway winners.
* @property {string} [drawing='Drawing: {timestamp}'] Displayed below "inviteToParticipate" in the giveaway embed. "{timestamp}" 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|EmbedFooterObject} [embedFooter='Powered by the discord-giveaways package'] The footer of the giveaway embed.
* @property {string|EmbedFooterObject} [embedFooter='{this.winnerCount} winner(s) • Powered by the discord-giveaways package'] The footer of the giveaway embed.
* @property {string} [noWinner='Giveaway cancelled, no valid participations.'] Displayed in the giveaway embed when there is 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} [winners='Winner(s):'] Displayed in the giveaway embed before the winners.
* @property {string} [endedAt='Ended at'] Displayed next to the embed footer, used to display the giveaway end date.
* @property {string} [hostedBy='Hosted by: {this.hostedBy}'] Below the "inviteToParticipate" message, in the description of the embed.
*/
Expand All @@ -22,9 +21,9 @@ exports.GiveawayMessages = {
inviteToParticipate: 'React with 🎉 to participate!',
winMessage: 'Congratulations, {winners}! You won **{this.prize}**!\n{this.messageURL}',
drawing: 'Drawing: {timestamp}',
embedFooter: 'Powered by the discord-giveaways package',
embedFooter: '{this.winnerCount} winner(s) • Powered by the discord-giveaways package',
noWinner: 'Giveaway cancelled, no valid participations.',
winners: 'winner(s)',
winners: 'Winner(s):',
endedAt: 'Ended at',
hostedBy: 'Hosted by: {this.hostedBy}'
};
Expand Down
23 changes: 6 additions & 17 deletions src/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,11 @@ class GiveawaysManager extends EventEmitter {
: giveaway.embedColor
)
.setFooter(
`${giveaway.winnerCount} ${giveaway.messages.winners}${
typeof giveaway.messages.embedFooter === 'object'
? giveaway.messages.embedFooter.text?.length > 0
? ' • ' + giveaway.messages.embedFooter.text
: ''
: ' • ' + giveaway.messages.embedFooter
}`,
typeof giveaway.messages.embedFooter === 'object'
? giveaway.messages.embedFooter.text?.length > 0
? giveaway.messages.embedFooter.text
: ''
: giveaway.messages.embedFooter,
giveaway.messages.embedFooter.iconURL
)
.setDescription(
Expand Down Expand Up @@ -111,16 +109,7 @@ class GiveawaysManager extends EventEmitter {
let formattedWinners = winners.map((w) => `<@${w.id}>`).join(', ');

const descriptionString = (formattedWinners) => {
const winnersString =
giveaway.messages.winners.substr(0, 1).toUpperCase() +
giveaway.messages.winners.substr(1, giveaway.messages.winners.length) +
': ' +
formattedWinners;

return (
winnersString +
(giveaway.hostedBy ? '\n' + giveaway.messages.hostedBy : '')
);
return giveaway.messages.winners + formattedWinners + (giveaway.hostedBy ? '\n' + giveaway.messages.hostedBy : '');
};

for (
Expand Down

0 comments on commit 823dd8f

Please sign in to comment.