noticeUwuzu/scripts/commands/report.ts

75 lines
2.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { ueuse } from "types/types";
import { Reply } from "./main.js";
import config from "../../config.js";
import sendMail from "../../src/mailer.js";
export default async function Report(data: ueuse) {
if (
data.abi === "none" ||
data.abi === ""
) {
console.log("報告(内容なし)", await Reply(`
追記に内容を記入してください。
(このユーズはもう利用できません。他のユーズで\`/report\`をまたご利用ください。)
`, data.uniqid));
return;
}
if (!config.emergency.isEnabled) {
console.log("報告(重要通知オフ)", await Reply(`
BOTの運営者によって重要通知が無効化されています。
そのため報告機能はご利用いただけません。
`, data.uniqid));
return;
}
if (!config.emergency.mail.isEnabled) {
console.log("報告(メールオフ)", await Reply(`
BOTの運営者によってメール送信機能が無効化されています。
そのため報告機能はご利用いただけません。
`, data.uniqid));
return;
}
if (!config.report.isEnabled) {
console.log("報告(機能オフ)", await Reply(`
BOTの運営者によって報告機能が無効化されています。
そのため報告機能はご利用いただけません。
`, data.uniqid));
return;
}
try {
sendMail({
to: config.emergency.mail.to,
subject: "【報告】BOT利用者からの報告",
text: `
※noticeUwuzu自動送信によるメールです
【報告】
BOT管理者さん、noticeUwuzu自動送信メールです。
@${data.account.userid}@${config.uwuzu.host}から/reportコマンドを利用した報告がありました。
報告元ユーズhttps://${config.uwuzu.host}/!${data.uniqid}
下記が内容となります。
${data.abi}
`,
});
console.log("報告(完了)", await Reply(`
報告が完了しました。
運営者は報告者、ユーズのURL、内容を確認できます。
--運営者からのメッセージ--
${config.report.message}
`, data.uniqid));
return;
} catch (err) {
console.log("/reportエラー", err);
console.log("報告(エラー)", await Reply(`
報告に失敗しました。
`, data.uniqid));
return;
}
}