noticeUwuzu/scripts/commands/delete.ts

53 lines
1.6 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 { meApi, ueuse } from "../../types/types";
import config from "../../config.js";
import { Reply } from "./main.js";
export default async function Delete(data: ueuse) {
const me: meApi = await (await fetch(`${config.uwuzu.host}/api/me/`, {
method: "POST",
cache: "no-store",
body: JSON.stringify({
token: config.uwuzu.apiToken,
}),
})).json()
const replyUeuse: ueuse = (await (await fetch(`${config.uwuzu.host}/api/ueuse/get`, {
method: "POST",
cache: "no-store",
body: JSON.stringify({
token: config.uwuzu.apiToken,
uniqid: data.replyid,
}),
})).json())["0"];
if (me.userid === replyUeuse.account.userid) {
const ueuseDelete = await (await fetch(`${config.uwuzu.host}/api/ueuse/delete`, {
method: "POST",
cache: "no-store",
body: JSON.stringify({
token: config.uwuzu.apiToken,
uniqid: data.replyid,
}),
})).json();
console.log("削除:", ueuseDelete);
if (ueuseDelete.success === true) {
console.log("削除通知:", await Reply(`
対象のユーズを削除しました。
`, data.uniqid));
} else {
console.log("削除失敗通知:", await Reply(`
対象のユーズを削除できませんでした。
`, data.uniqid));
}
return;
} else {
console.log("削除失敗通知(他人)", await Reply(`
削除するユーズが${me.username}のものではありません。
そのため削除できませんでした。
`, data.uniqid));
return;
}
}