mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-25 19:13:54 +00:00
Accept feedback and forward to Discord
This commit is contained in:
parent
26bfe37bf6
commit
cd2bd05aa7
4 changed files with 41 additions and 2 deletions
|
|
@ -82,6 +82,25 @@ export default class DiscordEventHandler {
|
|||
);
|
||||
break;
|
||||
}
|
||||
case "GOT_FEEDBACK": {
|
||||
const dest = await this.getChannel(Config.FEEDBACK_SKIN_CHANNEL_ID);
|
||||
const userMessage = action.message
|
||||
.split("\n")
|
||||
.map((line) => {
|
||||
return `> ${line}`;
|
||||
})
|
||||
.join("\n");
|
||||
let message = `Feedback:\n\n ${userMessage}`;
|
||||
if (action.email != null) {
|
||||
message += `\n\n--${action.email}`;
|
||||
}
|
||||
if (action.url != null) {
|
||||
message += `\n(${action.url})`;
|
||||
}
|
||||
|
||||
await dest.send(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ export type ApiAction =
|
|||
| { type: "ERROR_PROCESSING_UPLOAD"; id: string; message: string }
|
||||
| { type: "CLASSIC_SKIN_UPLOADED"; md5: string }
|
||||
| { type: "MODERN_SKIN_UPLOADED"; md5: string }
|
||||
| { type: "SKIN_UPLOAD_ERROR"; uploadId: string; message: string };
|
||||
| { type: "SKIN_UPLOAD_ERROR"; uploadId: string; message: string }
|
||||
| { type: "GOT_FEEDBACK"; message: string; email?: string, url?: string };
|
||||
|
||||
export type EventHandler = (event: ApiAction) => void;
|
||||
export type Logger = {
|
||||
|
|
|
|||
|
|
@ -113,6 +113,24 @@ router.post(
|
|||
})
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/feedback",
|
||||
asyncHandler(async (req, res) => {
|
||||
const payload = req.body as {
|
||||
email?: string;
|
||||
message: string;
|
||||
url?: string;
|
||||
};
|
||||
req.notify({
|
||||
type: "GOT_FEEDBACK",
|
||||
url: payload.url,
|
||||
message: payload.message,
|
||||
email: payload.email,
|
||||
});
|
||||
res.json({ message: "sent" });
|
||||
})
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/skins/status",
|
||||
asyncHandler(async (req, res) => {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@
|
|||
"fetch-metadata": "ts-node --transpile-only ./cli.ts fetch-metadata",
|
||||
"bot": "ts-node --transpile-only ./discord-bot/index.js",
|
||||
"cli": "ts-node --transpile-only ./cli.ts",
|
||||
"sync": "ts-node --transpile-only ./tasks/syncWithArchive.ts"
|
||||
"sync": "ts-node --transpile-only ./tasks/syncWithArchive.ts",
|
||||
"migrate": "knex migrate:latest"
|
||||
},
|
||||
"prettier": {},
|
||||
"devDependencies": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue