Kurt/revert discord to attempt deploy (#598)

* Force netlify build

builds are being canceled even though there are changes

* Revert "Upgrade packages (#594)"

This reverts commit 5531f2e0c1.

* Revert "Discord chat bot to announce projects (#590)"

This reverts commit 90fece9598.

* Revert "Force netlify build"

This reverts commit 315ebf0c59.

* Make sure project title is robust
This commit was merged in pull request #598.
This commit is contained in:
Kurt Hutten
2022-01-19 20:54:43 +11:00
committed by GitHub
parent 844a1f6961
commit 861b8374bf
9 changed files with 2357 additions and 3296 deletions

View File

@@ -9,7 +9,6 @@
"axios": "^0.21.1",
"cloudinary": "^1.23.0",
"cors": "^2.8.5",
"discord.js": "^13.5.1",
"express": "^4.17.1",
"human-id": "^2.0.1",
"middy": "^0.36.0",
@@ -22,4 +21,4 @@
"concurrently": "^6.0.0",
"nodemon": "^2.0.7"
}
}
}

View File

@@ -1,34 +0,0 @@
import {Client, Intents, MessageAttachment} from "discord.js"
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]})
export async function sendDiscordMessage(text: string, url?: string) {
if (!client.isReady()) {
console.error(`Discord: client is not ready to send message ("${text}")`);
} else {
const channel = await client.channels.fetch(process.env.DISCORD_CHANNEL_ID);
if (url) {
channel.send({ embeds: [{
title: text,
image: {
url: url,
},
}] });
} else {
channel.send(text)
}
}
}
client.on("ready", async () => {
console.log(`Discord: logged in as ${client.user.tag}`)
})
if (!process.env.DISCORD_TOKEN || !process.env.DISCORD_CHANNEL_ID) {
console.warn("Discord bot not configured - please set process.env.DISCORD_TOKEN and process.env.DISCORD_CHANNEL_ID to send discord chats");
} else {
console.log(`Discord: logging in (token ${process.env.DISCORD_TOKEN})`);
client.login(process.env.DISCORD_TOKEN);
}

View File

@@ -12,8 +12,6 @@ import {
} from 'src/services/helpers'
import { requireAuth } from 'src/lib/auth'
import { requireOwnership, requireProjectOwnership } from 'src/lib/owner'
import { sendDiscordMessage } from 'src/lib/discord'
export const projects = ({ userName }) => {
if (!userName) {
@@ -245,19 +243,7 @@ export const updateProjectImages = async ({
const [updatedProject] = await Promise.all([
projectPromise,
imageDestroyPromise,
]).then(async (result) => {
const { userName } = await db.user.findUnique({
where: { id: project.userId },
})
sendDiscordMessage([
`${userName} just added an image to their ${project.cadPackage} project:`,
` => ${project.title}`,
``,
`Check it out, leave a comment, make them feel welcome!`,
`https://cadhub.xyz/u/${userName}/${project.title}`
].join('\n'), `https://res.cloudinary.com/irevdev/image/upload/c_scale,w_700/v1/${mainImage}`)
return result
})
])
return updatedProject
}