Skip to content

Commit

Permalink
fix(general): remove what's new footer, /changelog always show latest
Browse files Browse the repository at this point in the history
  • Loading branch information
tuanddd committed Sep 12, 2023
1 parent 46c6d7a commit 5f8228d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 59 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
},
"dependencies": {
"@bonfida/spl-name-service": "^1.0.11",
"@consolelabs/mochi-rest": "^2.0.0",
"@consolelabs/mochi-ui": "^9.0.2",
"@consolelabs/mochi-rest": "^2.0.5",
"@consolelabs/mochi-ui": "^9.1.8",
"@discordjs/builders": "^0.12.0",
"@discordjs/rest": "^0.5.0",
"@haileybot/captcha-generator": "^1.7.0",
Expand All @@ -65,6 +65,7 @@
"dotenv": "^10.0.0",
"emoji-regex": "^10.2.1",
"ethers": "^5.4.7",
"fetch-to-curl": "^0.5.2",
"fuzzyset": "^1.0.7",
"ioredis": "^5.3.2",
"kafkajs": "^2.2.3",
Expand All @@ -89,11 +90,10 @@
"type-fest": "^3.12.0",
"vite": "^4.3.9",
"vite-node": "^0.32.4",
"vite-tsconfig-paths": "^4.2.0",
"vite-plugin-checker": "^0.6.1",
"vite-tsconfig-paths": "^4.2.0",
"ws": "^8.12.0",
"xstate": "^4.37.2",
"fetch-to-curl": "^0.5.2"
"xstate": "^4.37.2"
},
"lint-staged": {
"*.{js,ts}": "eslint --cache --fix",
Expand Down
20 changes: 10 additions & 10 deletions pnpm-lock.yaml

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

13 changes: 1 addition & 12 deletions src/commands/changelog/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,7 @@ const slashCmd: SlashCommand = {
return data
},
run: async function (i) {
const { ok, data: profile } = await api.profile.discord.getById({
discordId: i.user.id,
})
if (!ok)
return {
messageOptions: {
content: "Cannot show latest changelog",
},
}
const { changelog, markRead } = await api.getLatestChangelog(profile.id)
const changelog = api.getLatestChangelog()
if (!changelog) {
return {
messageOptions: {
Expand Down Expand Up @@ -55,8 +46,6 @@ const slashCmd: SlashCommand = {
}
}

markRead()

return null
},
help: async () => ({
Expand Down
33 changes: 1 addition & 32 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import Discord, { CommandInteraction } from "discord.js"
import Discord from "discord.js"
import {
APPLICATION_ID,
DISCORD_TOKEN,
Expand All @@ -20,8 +20,6 @@ import Redis from "ioredis"
import events from "listeners/discord"
import { getTipsAndFacts } from "cache/tip-fact-cache"
import api from "api"
import { DOT } from "utils/constants"
import { getEmbedFooter } from "ui/discord/embed"

let server: Server | null = null

Expand Down Expand Up @@ -120,35 +118,6 @@ function runHttpServer() {
})
}

// monkeypatch
const editReply = CommandInteraction.prototype.editReply
CommandInteraction.prototype.editReply = async function (
...args: Parameters<typeof editReply>
) {
const [payload] = args
if (typeof payload === "string" || !("embeds" in payload))
return editReply.apply(this, args)

const { ok: okProfile, data: profile } = await api.profile.discord.getById({
discordId: this.user.id,
})
if (okProfile) {
const { changelog } = await api.getLatestChangelog(profile.id)
if (changelog) {
const embed = payload.embeds?.at(0)
if (embed) {
const parts = embed.footer?.text?.split(` ${DOT} `)
if (parts?.length) {
parts[0] = "🌈 Mochi has a new update, check out /sup"
embed.footer!.text = getEmbedFooter(parts)
}
}
}
}

return editReply.apply(this, args)
}

// cleanup
// @ts-ignore
if (import.meta.hot) {
Expand Down

0 comments on commit 5f8228d

Please sign in to comment.