Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
bf5f4c7
Init ForgeGiveaways
xNickyDev Aug 3, 2025
9eb58aa
Added exports
xNickyDev Aug 3, 2025
71daa99
Small change
xNickyDev Aug 3, 2025
1554d82
test
xNickyDev Aug 3, 2025
76f9327
Rewrite
xNickyDev Oct 14, 2025
78d47f1
Prevent crash
xNickyDev Oct 14, 2025
703af9e
Test env variables
xNickyDev Oct 14, 2025
a8ddde3
Fix?
xNickyDev Oct 14, 2025
ad8b505
Added default messages
xNickyDev Oct 14, 2025
0f0c61f
Added event emitter
xNickyDev Oct 15, 2025
370ae4f
Tests
xNickyDev Oct 15, 2025
4838f8d
Test event data
xNickyDev Oct 15, 2025
e005dcf
Test event data
xNickyDev Oct 15, 2025
a334032
Fixed broken timestamp
xNickyDev Oct 16, 2025
22e56c2
Added context cache for giveaways
xNickyDev Oct 16, 2025
18e95a3
Optimized states and events
xNickyDev Oct 16, 2025
6fd286d
Added more functions
xNickyDev Oct 16, 2025
04bc982
Added reroll and end giveaways
xNickyDev Oct 16, 2025
87f4a50
Handle entries
xNickyDev Oct 17, 2025
f119b62
Added new forgotten entry events
xNickyDev Oct 17, 2025
ab01a09
Improve interaction behaviour
xNickyDev Oct 17, 2025
bf8aa3b
Pass old data first
xNickyDev Oct 17, 2025
46d18cf
Clone giveaways before modifying
xNickyDev Oct 17, 2025
79b6a9a
Fix giveaways not auto ending
xNickyDev Oct 17, 2025
6f8c8f3
Add requirements and more stuff
xNickyDev Oct 17, 2025
dc8d9f6
Fix setting requirements
xNickyDev Oct 17, 2025
65f964c
Improve end giveaway
xNickyDev Oct 17, 2025
22e7e14
Fix mentions and components
xNickyDev Oct 17, 2025
8dc7490
Test: Added database
xNickyDev Oct 18, 2025
3aa24c9
Prevent crash
xNickyDev Oct 18, 2025
2420216
Added transformer for array colums
xNickyDev Oct 18, 2025
8a9423c
Fix storing arrays and objects
xNickyDev Oct 18, 2025
2bfaf85
Handle id being undefined
xNickyDev Oct 18, 2025
b51f623
Make everything partial
xNickyDev Oct 18, 2025
d91f4fb
Fix not saving entries
xNickyDev Oct 18, 2025
54ad5b5
Add nullable back -_-
xNickyDev Oct 18, 2025
39476f1
Restructured whole database class
xNickyDev Oct 18, 2025
74c94d8
Fix incorrect extension names
xNickyDev Oct 18, 2025
c20415d
Prevent repo being undefined?
xNickyDev Oct 18, 2025
872f805
Fix events not listening?
xNickyDev Oct 18, 2025
a7a9f23
Fix crash on startup?
xNickyDev Oct 18, 2025
6e707be
Oopsies
xNickyDev Oct 18, 2025
fbb00cf
Desperate
xNickyDev Oct 18, 2025
31a7ff9
Another attempt
xNickyDev Oct 18, 2025
c86dada
Test
xNickyDev Oct 18, 2025
6587647
Mark database as possible undefined
xNickyDev Oct 18, 2025
53227a3
Fix incorrect timestamp
xNickyDev Oct 18, 2025
ce5cc9c
Improve current sytems
xNickyDev Oct 18, 2025
1c579e3
Better error messages
xNickyDev Oct 18, 2025
b7697b8
Possible fix
xNickyDev Oct 18, 2025
c6b8c85
Test
xNickyDev Oct 18, 2025
bef5b71
Test
xNickyDev Oct 18, 2025
bc9c8cb
Small fixes
xNickyDev Oct 19, 2025
052fc62
Added giveaways restoring
xNickyDev Oct 19, 2025
cfb7f6d
Different orders
xNickyDev Oct 19, 2025
8f92ffa
Wait for the client to become ready
xNickyDev Oct 19, 2025
a096f61
Some iimprovements
xNickyDev Oct 19, 2025
e753fb2
Small fix
xNickyDev Oct 19, 2025
b58ec0e
Make entities public
xNickyDev Oct 19, 2025
3dd29f8
Add missing stuff
xNickyDev Oct 19, 2025
7bdbb86
Small changes
xNickyDev Oct 19, 2025
dbdc65f
Remove unnecessary statements
xNickyDev Oct 19, 2025
aba12ed
Clear up dist
xNickyDev Oct 19, 2025
7cb644c
New event
xNickyDev Oct 19, 2025
45f0138
Finish default messages
xNickyDev Oct 19, 2025
ce4a115
Add unique param for rerolls
xNickyDev Oct 19, 2025
755e602
Added database functions
xNickyDev Oct 20, 2025
3a55335
More improvements and additions
xNickyDev Oct 20, 2025
67e8dd6
Test fix
xNickyDev Oct 20, 2025
90b54ed
Debug logs
xNickyDev Oct 20, 2025
37b5be0
Use cloned context
xNickyDev Oct 20, 2025
0592371
Support interaction context in entry events
xNickyDev Oct 21, 2025
fbdb020
Fix
xNickyDev Oct 21, 2025
a96be96
Test
xNickyDev Oct 21, 2025
e3ed244
Add interaction obj
xNickyDev Oct 21, 2025
adf59ad
Add helper function
xNickyDev Oct 21, 2025
1d69640
Quick test
xNickyDev Oct 21, 2025
b054d0d
Allow only one start event
xNickyDev Oct 21, 2025
facd5b5
Better handling of interactions
xNickyDev Oct 21, 2025
b60a55f
Fix not throwing error?
xNickyDev Oct 21, 2025
1bf2484
Add error throw on startup
xNickyDev Oct 21, 2025
434f1dd
More clear error message
xNickyDev Oct 21, 2025
04c3e6a
Add giveaway category, finish README
xNickyDev Oct 22, 2025
bf70491
Rename event
xNickyDev Oct 22, 2025
4b1313e
Use correct package name
xNickyDev Oct 22, 2025
2851bfe
1.0.1
xNickyDev Oct 22, 2025
e406d7d
Update package
xNickyDev Oct 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.env
8 changes: 8 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*/__tests__/
docs/
src/
metadata/
.vscode/
.github/
.env
tsconfig.json
141 changes: 140 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,140 @@
# ForgeGiveaways
<div align="center">

<img height="150" width="150" src="https://github.com/user-attachments/assets/9969c07b-2608-4ddd-930b-487485c07d80" alt="ForgeGiveaways">

# ForgeGiveaways
ForgeGiveaways is a lightweight, flexible, and reliable extension for managing giveaways. Fully customizable features let you automate, track, and control every giveaway seamlessly.

<a href="https://github.com/tryforge/ForgeGiveaways/"><img src="https://img.shields.io/github/package-json/v/tryforge/ForgeGiveaways/main?label=@tryforge/forge.giveaways&color=5c16d4" alt="@tryforge/forge.giveaways"></a>
<a href="https://github.com/tryforge/ForgeScript/"><img src="https://img.shields.io/github/package-json/v/tryforge/ForgeScript/main?label=@tryforge/forgescript&color=5c16d4" alt="@tryforge/forgescript"></a>
<a href="https://discord.gg/hcJgjzPvqb"><img src="https://img.shields.io/discord/997899472610795580?logo=discord" alt="Discord"></a>

</div>

---

## Contents

1. [Installation](#installation)
2. [Custom Messages](#custom-messages)
3. [Handling Interactions](#handling-interactions)
4. [Documentation](https://docs.botforge.org/p/ForgeGiveaways/)

<h3 align="center">Installation</h3><hr>

> [!WARNING]
> **ForgeGiveaways** requires the extension [**ForgeDB**](https://docs.botforge.org/p/ForgeDB/) installed in order to operate.

1. Run the following command to install the required `npm` packages:
```bash
npm i @tryforge/forge.giveaways @tryforge/forge.db
```

2. Here’s an example of how your main file should look:
```js
const { ForgeClient } = require("@tryforge/forgescript")
const { ForgeGiveaways } = require("@tryforge/forge.giveaways")
const { ForgeDB } = require("@tryforge/forge.db")

const giveaways = new ForgeGiveaways({
events: [
"giveawayStart",
"giveawayEnd"
],
useDefault: true
})

const client = new ForgeClient({
...options // The options you currently have
extensions: [
giveaways,
new ForgeDB()
]
})

client.commands.load("commands")
giveaways.commands.load("giveaways")

client.login("YourToken")
```

> [!NOTE]
> View all available client options [here](https://github.com/tryforge/ForgeGiveaways/blob/main/src/index.ts#L8).

<h3 align="center">Custom Messages</h3><hr>

You can disable the default messages by setting `useDefault: false` in the client options, and override them with custom messages emitted through events. Use desired functions to retrieve information about the current giveaway.

> [!WARNING]
> Only **one** `giveawayStart` event is allowed per client instance!

#### Examples
When using custom start messages, your event **must return the message ID** of the sent giveaway message. To ensure that only the message ID is returned (and no additional text), use the `$return[]` function.

```js
module.exports = {
type: "giveawayStart",
code: `
$return[
$sendMessage[$giveawayChannelID;
$addContainer[
$addTextDisplay[### 🎉 Giveaway 🎉]
$addSeparator
$addTextDisplay[**Prize:** $giveawayPrize\n**Winners:** $giveawayWinnersCount]
$addSeparator
$addActionRow
$addButton[giveawayEntry-$giveawayID;Join;Secondary;🎉]
;Green]
;true]
]
`
}
```

```js
module.exports = {
type: "giveawayEnd",
code: `
$sendMessage[$giveawayChannelID;
$reply[$giveawayChannelID;$giveawayMessageID;true]
🏆 **Winners:** <@$newGiveaway[winners;>, <@]>
]
`
}
```

<h3 align="center">Handling Interactions</h3><hr>

The custom ID for giveaway entry buttons must follow this exact format:
```
giveawayEntry-GIVEAWAY_ID
```
<sub>*Replace "GIVEAWAY_ID" with the actual ID of the giveaway. See the `giveawayStart` example above for reference.*</sub>

\
Through the entry-related events, you can send custom responses directly to the current interaction context.

#### Examples
```js
module.exports = {
type: "giveawayEntryAdd",
code: `
$interactionReply[
$ephemeral
You have joined this giveaway as **$ordinal[$@[,]giveawayEntries]** participant!
]
`
}
```

```js
module.exports = {
type: "giveawayEntryRemove",
code: `
$interactionReply[
$ephemeral
You have left this giveaway!
]
`
}
```
2 changes: 2 additions & 0 deletions dist/commit.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=commit.d.ts.map
1 change: 1 addition & 0 deletions dist/commit.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions dist/commit.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/commit.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions dist/docgen.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=docgen.d.ts.map
1 change: 1 addition & 0 deletions dist/docgen.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions dist/docgen.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/docgen.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions dist/events/databaseConnect.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { GiveawaysEventHandler } from "../handlers";
declare const _default: GiveawaysEventHandler<"databaseConnect">;
export default _default;
//# sourceMappingURL=databaseConnect.d.ts.map
1 change: 1 addition & 0 deletions dist/events/databaseConnect.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions dist/events/databaseConnect.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/events/databaseConnect.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions dist/events/giveawayEnd.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { GiveawaysEventHandler } from "../handlers";
declare const _default: GiveawaysEventHandler<"giveawayEnd">;
export default _default;
//# sourceMappingURL=giveawayEnd.d.ts.map
1 change: 1 addition & 0 deletions dist/events/giveawayEnd.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions dist/events/giveawayEnd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/events/giveawayEnd.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions dist/events/giveawayEntryAdd.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { GiveawaysEventHandler } from "../handlers";
declare const _default: GiveawaysEventHandler<"giveawayEntryAdd">;
export default _default;
//# sourceMappingURL=giveawayEntryAdd.d.ts.map
1 change: 1 addition & 0 deletions dist/events/giveawayEntryAdd.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions dist/events/giveawayEntryAdd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/events/giveawayEntryAdd.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions dist/events/giveawayEntryRemove.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { GiveawaysEventHandler } from "../handlers";
declare const _default: GiveawaysEventHandler<"giveawayEntryRemove">;
export default _default;
//# sourceMappingURL=giveawayEntryRemove.d.ts.map
1 change: 1 addition & 0 deletions dist/events/giveawayEntryRemove.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading