-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Post Discord channel message on points earned (#83)
* feat: Post Discord channel message on points earned * added trigger-example in gitignore * resolve merge conflicts --------- Co-authored-by: Johannes <[email protected]>
- Loading branch information
Showing
11 changed files
with
197 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,4 +37,6 @@ yarn-error.log* | |
next-env.d.ts | ||
|
||
.vscode | ||
.contentlayer | ||
.contentlayer | ||
|
||
jobs/examples.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { DISCORD_POINTS_MESSAGE_TRIGGER_ID } from "@/lib/constants"; | ||
import { discordApi } from "@/lib/discord"; | ||
import { triggerDotDevClient } from "@/trigger"; | ||
import { eventTrigger } from "@trigger.dev/sdk"; | ||
import z from "zod"; | ||
|
||
triggerDotDevClient.defineJob({ | ||
id: "discord-points-message", | ||
name: "Discord award points message", | ||
version: "0.0.1", | ||
trigger: eventTrigger({ | ||
name: DISCORD_POINTS_MESSAGE_TRIGGER_ID, | ||
schema: z.object({ | ||
channelId: z.string(), | ||
message: z.string(), | ||
}), | ||
}), | ||
run: async (payload, io) => { | ||
const { channelId, message } = payload; | ||
|
||
await io.runTask( | ||
"Post awarded message to Discord channel", | ||
async () => { | ||
const channelsAPI = discordApi.channels; | ||
await channelsAPI.createMessage(channelId, { content: message }); | ||
}, | ||
|
||
// Add metadata to the task to improve how it displays in the logs | ||
{ name: "Send message", icon: "discord" } | ||
); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// export all your job files here | ||
|
||
export * from "./issueReminder" | ||
export * from "./issueReminder"; | ||
export * from "./discordPointsMessage"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { env } from "@/env.mjs"; | ||
// @ts-ignore | ||
import { API } from "@discordjs/core/http-only"; | ||
import { REST } from "@discordjs/rest"; | ||
|
||
const rest = new REST({ version: "10" }).setToken(env.DISCORD_BOT_TOKEN!); | ||
export const discordApi = new API(rest); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,12 @@ | |
"@aws-sdk/s3-presigned-post": "^3.577.0", | ||
"@aws-sdk/s3-request-presigner": "^3.577.0", | ||
"@hookform/resolvers": "^3.4.0", | ||
"@aws-sdk/client-s3": "^3.540.0", | ||
"@aws-sdk/s3-presigned-post": "^3.540.0", | ||
"@aws-sdk/s3-request-presigner": "^3.540.0", | ||
"@discordjs/core": "1.2.0", | ||
"@discordjs/rest": "2.3.0", | ||
"@hookform/resolvers": "^3.3.4", | ||
"@next-auth/prisma-adapter": "^1.0.7", | ||
"@octokit/auth-app": "^6.1.1", | ||
"@octokit/rest": "^20.1.1", | ||
|
@@ -99,7 +105,12 @@ | |
"typescript": "^5.4.5" | ||
}, | ||
"packageManager": "[email protected]", | ||
"pnpm": { | ||
"overrides": { | ||
"undici": "5.27.0" | ||
} | ||
}, | ||
"trigger.dev": { | ||
"endpointId": "testing-bHhV" | ||
"endpointId": "oss-gg-dev-ND8k" | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { TriggerClient } from "@trigger.dev/sdk"; | ||
import { TRIGGER_API_KEY, TRIGGER_API_URL } from "@/lib/constants"; | ||
import { TriggerClient } from "@trigger.dev/sdk"; | ||
|
||
export const triggerDotDevClient = new TriggerClient({ | ||
id: "testing-bHhV", | ||
id: "oss-gg-dev-ND8k", | ||
apiKey: TRIGGER_API_KEY, | ||
apiUrl: TRIGGER_API_URL, | ||
}); |