mirror of
https://github.com/ow-mods/ow-mod-db.git
synced 2025-12-11 20:15:24 +01:00
fix discord notification with image
This commit is contained in:
parent
ee3eeb5616
commit
c01eda2e92
2
.github/workflows/pr-from-issue.yml
vendored
2
.github/workflows/pr-from-issue.yml
vendored
@ -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"
|
||||
|
||||
2
fetch-mods/constants.ts
Normal file
2
fetch-mods/constants.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export const thumbnailUrlBase =
|
||||
"https://raw.githubusercontent.com/ow-mods/ow-mod-db/master/thumbnails";
|
||||
@ -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) : ""
|
||||
}`,
|
||||
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user