diff --git a/.github/workflows/pr-from-issue.yml b/.github/workflows/pr-from-issue.yml index 525acdf839..999543a276 100644 --- a/.github/workflows/pr-from-issue.yml +++ b/.github/workflows/pr-from-issue.yml @@ -53,5 +53,5 @@ jobs: branch-suffix: random delete-branch: true token: ${{ secrets.GH_TOKEN }} - commiter: "${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>" + committer: "${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>" labels: "add-mod" diff --git a/fetch-mods/constants.ts b/fetch-mods/constants.ts new file mode 100644 index 0000000000..3906c81fa4 --- /dev/null +++ b/fetch-mods/constants.ts @@ -0,0 +1,2 @@ +export const thumbnailUrlBase = + "https://raw.githubusercontent.com/ow-mods/ow-mod-db/master/thumbnails"; diff --git a/fetch-mods/send-discord-notifications.ts b/fetch-mods/send-discord-notifications.ts index a3b285b8fe..12836976a1 100644 --- a/fetch-mods/send-discord-notifications.ts +++ b/fetch-mods/send-discord-notifications.ts @@ -1,5 +1,5 @@ import axios from "axios"; -import { diffieHellman } from "crypto"; +import { thumbnailUrlBase } from "./constants"; import { DiffItem } from "./get-diff"; function getNotificationTitle(diffItem: DiffItem) { @@ -64,7 +64,7 @@ function getEmbed(diffItem: DiffItem) { url: `http://outerwildsmods.com/mods/${diffItem.nextMod.slug}`, color: getNotificationColor(diffItem), [getNotificationImageKey(diffItem)]: { - url: diffItem.nextMod.thumbnail.openGraph, + url: `${thumbnailUrlBase}/${diffItem.nextMod.thumbnail.openGraph}`, }, }; } @@ -86,7 +86,7 @@ export async function sendDiscordNotifications( (diffItem) => diffItem.diffType === "add" ); - axios.post(discordHookUrl, { + await axios.post(discordHookUrl, { content: `${pingRoleId(discordModUpdateRoleId)} ${ containsNewMod ? pingRoleId(discordNewModRoleId) : "" }`, diff --git a/fetch-mods/test/secrets.template.json b/fetch-mods/test/secrets.template.json index 6313113d4a..de49ca227b 100644 --- a/fetch-mods/test/secrets.template.json +++ b/fetch-mods/test/secrets.template.json @@ -2,6 +2,6 @@ "ghToken": "Make a copy of this file, name it secrets.json, and replace this string with your GH token.", "discordHookUrl": "Replace this string with your Discord hook URL", "discordModHookUrls": { - "uniqueName": "Replace this string with this mod's Discord hook URL" + "[mod unique name here]": "Replace this string with this mod's Discord hook URL" } } diff --git a/fetch-mods/test/test.ts b/fetch-mods/test/test.ts index b7eca873b9..656fe8f4b0 100644 --- a/fetch-mods/test/test.ts +++ b/fetch-mods/test/test.ts @@ -1,7 +1,7 @@ import { fetchMods } from "../fetch-mods"; import modsJson from "./mods.json"; // import { discordHookUrl, ghToken, discordModHookUrls } from "./secrets.json"; -import { googleServiceAccount } from "./secrets.json"; +import { discordHookUrl } from "./secrets.json"; import nextDatabase from "./next-database.json"; import previousDatabase from "./previous-database.json"; import { getDiff } from "../get-diff"; @@ -11,9 +11,57 @@ import { getViewCounts } from "../get-view-counts"; import { getInstallCounts } from "../get-install-counts"; async function test() { - const installCounts = await getInstallCounts(googleServiceAccount); - - console.log("installCounts", toJsonString(installCounts)); + sendDiscordNotifications( + discordHookUrl, + "", + "", + [ + { + diffType: "update", + nextMod: { + name: "name", + uniqueName: "uniqueName", + slug: "slug", + description: "description", + author: "author", + repo: "repo", + latestReleaseDate: "latestReleaseDate", + firstReleaseDate: "firstReleaseDate", + latestReleaseDescription: "latestReleaseDescription", + latestPrereleaseDescription: "latestPrereleaseDescription", + tags: [], + thumbnail: { + main: "nomaivr.webp", + openGraph: "nomaivr-static.webp", + }, + downloadUrl: "downloadUrl", + downloadCount: 10, + version: "2.0.0", + }, + previousMod: { + name: "name", + uniqueName: "uniqueName", + slug: "slug", + description: "description", + author: "author", + repo: "repo", + latestReleaseDate: "latestReleaseDate", + firstReleaseDate: "firstReleaseDate", + latestReleaseDescription: "latestReleaseDescription", + latestPrereleaseDescription: "latestPrereleaseDescription", + tags: [], + thumbnail: { + main: "nomaivr.webp", + openGraph: "nomaivr-static.webp", + }, + downloadUrl: "downloadUrl", + downloadCount: 10, + version: "1.0.0", + }, + }, + ], + {} + ); } test();