Skip to content

Commit

Permalink
feat: v1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowplay1 committed Nov 16, 2024
1 parent 5602a8a commit 77bf314
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
8 changes: 8 additions & 0 deletions docs/general/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@

## ⏰ | Changelog

**v1.1.1**:
- Minor JSDoc & types fixes.
- Now the array of giveaway winners is being represented in a `Set` instead of an array.
- Fixed the crash when giveaway guild/host member/channel **cannot** be fetched.
- Fixed the `embedStrings.finish.endMessage` being **unused**.
- Fixed the default giveaway button text being **forced** if it's not specified.
- Minor bug fixes.

**v1.1.0**:
- Fixed `DiscordID` types bug in `Giveaways.start()` method.
- Fixed the incorrect giveaway end timestamp being assigned on giveaway start.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "discord-giveaways-super",
"version": "1.1.0",
"version": "1.1.1",
"description": "Create and manage giveaways in Discord.",
"types": "./types/src/index.d.ts",
"main": "dist/src/index.js",
Expand Down
34 changes: 19 additions & 15 deletions src/lib/Giveaway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ import { replaceGiveawayKeys } from '../structures/giveawayTemplate'
*/
export class Giveaway<
TDatabaseType extends DatabaseType
> implements Omit<IGiveaway, 'hostMemberID' | 'channelID' | 'guildID' | 'entries' | 'participantsFilter'> {
> implements Omit<
IGiveaway,
'hostMemberID' | 'channelID' | 'guildID' | 'entries' | 'winners' | 'participantsFilter'
> {

/**
* {@link Giveaways} instance.
Expand Down Expand Up @@ -152,9 +155,9 @@ export class Giveaway<
* Array of used ID who have won in the giveaway.
*
* Don't confuse this property with `winnersCount`, the setting that dertermines how many users can win in the giveaway.
* @type {Array<DiscordID<string>>}
* @type {Set<DiscordID<string>>}
*/
public winners: Array<DiscordID<string>> = []
public winners: Set<DiscordID<string>> = new Set()

/**
* Determines if the giveaway was ended in database.
Expand Down Expand Up @@ -292,13 +295,14 @@ export class Giveaway<
this.entries = new Set<DiscordID<string>>(giveaway.entries)

/**
* Array of used ID who have won in the giveaway.
* Set of used ID who have won in the giveaway.
*
* Don't confuse this property with `winnersCount`,
* the setting that dertermines how many users can win in the giveaway.
* @type {Array<DiscordID<string>>}
* the **giveaway configuration setting** that
* dertermines how many users can win in the giveaway.
* @type {Set<DiscordID<string>>}
*/
this.winners = giveaway.winners || []
this.winners = new Set<DiscordID<string>>(giveaway.winners)

/**
* Number of users who have joined the giveaway.
Expand Down Expand Up @@ -639,7 +643,7 @@ export class Giveaway<
this.isEnded = true
this.raw.isEnded = true

this.winners = winnersIDs.map(winnerID => winnerID.slice(2, -1))
this.winners = new Set(winnersIDs.map(winnerID => winnerID.slice(2, -1)))
this.raw.winners = winnersIDs.map(winnerID => winnerID.slice(2, -1))

this.endedTimestamp = endedTimestamp
Expand Down Expand Up @@ -676,7 +680,7 @@ export class Giveaway<
const rerolledEmbed = this._messageUtils.buildGiveawayEmbed(this.raw, rerollMessage, winnersIDs)
const giveawayMessage = await this.channel.messages.fetch(this.messageID)

this.winners = winnersIDs.map(winnerID => winnerID.slice(2, -1))
this.winners = new Set(winnersIDs.map(winnerID => winnerID.slice(2, -1)))
this.raw.winners = winnersIDs.map(winnerID => winnerID.slice(2, -1))

this._giveaways.database.pull(`${this.guild.id}.giveaways`, giveawayIndex, this.raw)
Expand Down Expand Up @@ -1109,13 +1113,13 @@ export class Giveaway<
.replaceAll(this.host.username, newGiveawayHost.username)
.replaceAll(this.host.discriminator, newGiveawayHost.discriminator)
.replaceAll(this.host.tag, newGiveawayHost.tag)
.replaceAll(this.host.avatar, newGiveawayHost.avatar)
.replaceAll(this.host.avatar!, newGiveawayHost.avatar!)
.replaceAll(this.host.defaultAvatarURL, newGiveawayHost.defaultAvatarURL)
.replaceAll(this.host.bot, newGiveawayHost.bot)
.replaceAll(this.host.system, newGiveawayHost.system)
.replaceAll(this.host.banner, newGiveawayHost.banner)
.replaceAll(this.host.createdAt, newGiveawayHost.createdAt)
.replaceAll(this.host.createdTimestamp, newGiveawayHost.createdTimestamp)
.replaceAll(this.host.bot.toString(), newGiveawayHost.bot.toString())
.replaceAll(this.host.system.toString(), newGiveawayHost.system.toString())
.replaceAll(this.host.banner!, newGiveawayHost.banner!)
.replaceAll(this.host.createdAt.toString(), newGiveawayHost.createdAt.toString())
.replaceAll(this.host.createdTimestamp.toString(), newGiveawayHost.createdTimestamp.toString())
.replaceAll(this.host.id, newGiveawayHost.id)
}
}
Expand Down

0 comments on commit 77bf314

Please sign in to comment.