Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
085deb6
Added soundboard support, bump versions
xNickyDev Apr 29, 2025
1ff604a
Small improvements
xNickyDev Apr 29, 2025
620e98e
Added forgotten state functions
xNickyDev Apr 29, 2025
1643cdb
Added components v2 support
xNickyDev May 1, 2025
3ce6794
Fixed edit component functions, bump djs
xNickyDev May 3, 2025
7de3a29
Added team functions, changed $loop last arg
xNickyDev May 9, 2025
5265ca9
Fixed $loadComponents, $fetchResponse, $fetchComponents
xNickyDev May 17, 2025
ac8c2b5
Fixed $memberAvatar and $memberBanner
xNickyDev May 22, 2025
e51ff50
Updated extensions guide
xNickyDev May 23, 2025
4066cc4
Added desc arg to $attachment, deleted $test
xNickyDev May 23, 2025
0abe722
Fixed count operator for empty strings
xNickyDev May 24, 2025
9451cf3
Restructured changelogs.json
xNickyDev May 24, 2025
bfa7f15
Updated extensions guide
xNickyDev May 25, 2025
953edbe
Added $getSnapshots
xNickyDev May 27, 2025
7f1f479
Added $typeof, $syncGuildTemplate and new arg to $createGuild
xNickyDev May 28, 2025
a018d66
Added $guildTemplateCode
xNickyDev May 28, 2025
36cd819
Fixed wrong output types
xNickyDev Jun 1, 2025
8ee8ae0
Delete .github/dependabot.yml
aggelos-007 Jun 2, 2025
601e205
Added $cloneRole, $guildInviteExists and new metadata
xNickyDev Jun 3, 2025
49a58d9
Small fix
xNickyDev Jun 3, 2025
f62e7ef
Fixed $guildVanityCode, optimized $unparseDigital
xNickyDev Jun 6, 2025
7e7c2d6
Added $messageEmojis
xNickyDev Jun 7, 2025
8dffec0
Fixed $arrayCreate not defaulting to empty array
xNickyDev Jun 8, 2025
62d0caa
Fixed prev change on component builders
xNickyDev Jun 8, 2025
f75ad68
Fixed stacking action rows in containers
xNickyDev Jun 8, 2025
2b85858
Added rest option to custom function params
xNickyDev Jun 11, 2025
cc4980d
Small changes, bump djs
xNickyDev Jun 16, 2025
2a9a7a9
Added activity support, small fixes
xNickyDev Jun 17, 2025
2a4831f
Added new functions
xNickyDev Jun 21, 2025
c721475
Allowed components for webhook messages, added threadID to $webhookEd…
xNickyDev Jun 23, 2025
794b95f
Added $isActivityCommand and activityCommand type
xNickyDev Jun 23, 2025
b4e0c56
Added new functions, bump djs
xNickyDev Jun 26, 2025
0d14265
Fixed $httpRequest causes crash on error, small other fixes
xNickyDev Jun 30, 2025
4b7f0d3
Support editing select menus in cv2
xNickyDev Jul 4, 2025
2976bb4
Small fixes
xNickyDev Jul 11, 2025
7f11afd
Removed deprecated reason args of thread member functions
xNickyDev Jul 11, 2025
6af33aa
Fixed some time functions
xNickyDev Jul 20, 2025
e9ef8fb
Fixed generating paths
xNickyDev Jul 29, 2025
fb8db8a
Fixed buffers and generating enums
xNickyDev Aug 15, 2025
eb07339
Fixed $getComponents (cv2 support)
xNickyDev Aug 18, 2025
de953fe
Fixed various component functions
xNickyDev Aug 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
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"env": {
"browser": true,
"commonjs": true,
"es2021": true
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
Expand Down
11 changes: 0 additions & 11 deletions .github/dependabot.yml

This file was deleted.

5 changes: 4 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ metadata/
CONTRIBUTING.md
EXTENSIONS.md
.env
tsconfig.json
tsconfig.json
.eslintrc.json
.prettierrc
.prettierignore
159 changes: 150 additions & 9 deletions EXTENSIONS.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,161 @@
# Creating your first extension
# Creating your first Extension

## Before you start...
Make sure you have `node` installed on your machine, you can verify this by using `node -v` on a terminal like Windows CMD.
> If you don't have `node` installed, you can get it [here](https://nodejs.org/en/download)

## Creating a workspace
Create a folder, somewhere in your machine, let's name it `my-first-extension`, now let's open it with an IDE like Visual Studio Code.
> If you don't have `node` installed, you can get it [here](https://nodejs.org/en/download).

## Creating a Workspace
Create a new folder, somewhere in your machine, let's name it `my-first-extension`, now let's open it with an IDE like Visual Studio Code.

Once opened, open a terminal, and run the following commands:
1. ```bash
npm i --g typescript
```
2. ```bash
npm init --y
```
3. ```bash
npm i typescript github:tryforge/ForgeScript#dev --save-dev
```
4. ```bash
tsc --init --target es2022 --rootdir src --outdir dist
```

Now then, let's create a folder called `src`, which is where all our code will reside.

## Compiling your Changes
Before you push your changes to GitHub, make sure to compile them. We use TypeScript therefore compiling is a mandatory step in the development of an extension.

After you are done with your changes, run the following command in the terminal:
```bash
npm i --g typescript
tsc
```

npm init --y
Technically, after the process has finished, everything is now ready to be pushed to your repository on GitHub.

npm i typescript github:tryforge/ForgeScript#dev --save-dev
If you want to generate metadata and docs for your extension, **do not** push your changes already after compiling. Instead, read [the next step](#generating-metadata--docs).

tsc --init --target es2022 --rootdir src --outdir dist
## Generating Metadata & Docs
In order to generate metadata and docs for your extension, you will need to create a new `docgen.ts` file in your `src` root folder containing this code:
```ts
import { generateMetadata } from "@tryforge/forgescript"

generateMetadata(`${__dirname}/native`, "native")
```
> *Replace `native` if your native functions folder has a different name.*

Now then, let's create a folder called `src`, which is where all our code will reside.
\
Then, add the following script to the existing scripts in your `package.json` file:

```json
{
"scripts": {
"docgen": "tsc && typedoc src/index.ts && node dist/docgen"
},
}
```
\
Now, **after** compiling your changes, run this command:
```bash
npm run docgen
```

Once this step is done you are ready to push everything to GitHub. If you prefer adding changelog notes to your commits, head over to [the next step](#initializing-changelog-notes).

---

### Initializing Changelog Notes
> Before initializing, make sure you have completed the [previous step](#generating-metadata--docs). If you do not want to add a note to your commit, simply stick to `npm run docgen`.

First you need to add a new function by creating a `prompt.ts` file somewhere in your `src` root folder containing the code below without any modification:
```ts
import { stdin, stdout } from "process"
import { createInterface } from "readline"

export default async function(q: string) {
const itf = createInterface(stdin, stdout)
return new Promise<string>(r => {
itf.question(q, input => {
itf.close()
r(input)
})
})
}
```
\
Create a new `commit.ts` file in your `src` root folder. Copy and paste the code below into the newly created file. You may need to adjust the import for the `prompt` function, depending on where you have this file located in your project.
```ts
import { execSync } from "child_process"
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs"
import prompt from "./functions/prompt"
import { join } from "path"

const path = "./metadata"
if (!existsSync(path)) mkdirSync(path)

const version = require("../package.json").version

async function main() {
let skip = false

const msg = (await prompt("Please write the commit message: ")).replace(
/(--?(\w+))/gim, (match) => {
const name = /(\w+)/.exec(match)![1].toLowerCase()

switch (name) {
case "hide": {
skip = true
break
}

default: {
throw new Error(`--${name} is not a valid flag.`)
}
}

return ""
}
).trim()

const fileName = join(path, "changelogs.json")
const json: Record<string, object[]> = existsSync(fileName) ? JSON.parse(readFileSync(fileName, "utf-8")) : {}
json[version] ??= []

if (!skip) {
json[version].unshift({
message: msg,
timestamp: new Date(),
author: execSync("git config user.name").toString().trim()
})
writeFileSync(fileName, JSON.stringify(json), "utf-8")
}

const branch = await prompt("Write the branch name to push to (defaults to dev): ") || "dev"
const escapedMsg = msg.replace(/\$/g, "\\$")

execSync("git branch -M " + branch + " && git add . && git commit -m \"" + escapedMsg + "\" && git push -u origin " + branch, {
stdio: "inherit"
})
}

// Nothing
main()
```
\
Add the following script to the existing scripts in your `package.json` file:
```json
{
"scripts": {
"commit": "npm run docgen && node dist/commit"
},
}
```
\
Instead of running `npm run docgen` after compiling, run:
```bash
npm run commit
```
This command allows you to add an additional changelog note to your commit and automatically pushes your changes. If your extension was added as an official or community extension, all changelog notes will be displayed in the "Changelog" tab on the docs.

> Note that you should not run both scripts for the same commit. Either run `docgen` or `commit`, whatever suits your needs best.
6 changes: 5 additions & 1 deletion dist/commit.js

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

2 changes: 1 addition & 1 deletion dist/commit.js.map

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

3 changes: 2 additions & 1 deletion dist/core/Interpreter.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Message, VoiceState, Presence, Role, GuildMember, GuildEmoji, User, GuildAuditLogsEntry, Channel, Guild, StageInstance, Invite, PartialMessage, Sticker, GuildBan, GuildScheduledEvent, Entitlement, PollAnswer, AutoModerationRule, VoiceChannelEffect } from "discord.js";
import { Message, VoiceState, Presence, Role, GuildMember, GuildEmoji, User, GuildAuditLogsEntry, Channel, Guild, StageInstance, Invite, PartialMessage, Sticker, GuildBan, GuildScheduledEvent, Entitlement, PollAnswer, AutoModerationRule, VoiceChannelEffect, SoundboardSound, PartialSoundboardSound } from "discord.js";
import { IExtendedCompilationResult } from ".";
import { Sendable, BaseCommand, Context, Container } from "../structures";
import { ForgeClient } from "./ForgeClient";
Expand All @@ -23,6 +23,7 @@ export interface IStates {
invite: Invite;
sticker: Sticker;
automodRule: AutoModerationRule;
soundboardSound: SoundboardSound | PartialSoundboardSound;
}
export type States = {
[K in keyof IStates]?: {
Expand Down
2 changes: 1 addition & 1 deletion dist/core/Interpreter.d.ts.map

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

Loading
Loading