Last active
December 19, 2024 18:27
-
-
Save thewh1teagle/af8a90f7dd9708e3a99d64f84e298b5b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
Supress @everyone and @here mentions across all Discord servers. | |
1. Open https://discord.com | |
2. Extract the token from dev tools -> Local Storage -> token | |
3. Run | |
*/ | |
const token = "your token"; | |
const headers = { | |
authorization: token, | |
"content-type": "application/json", | |
}; | |
async function fetchserverIds() { | |
// Fetch servers | |
var resp = await fetch("https://discord.com/api/v9/users/@me/guilds", { | |
headers, | |
method: "GET", | |
mode: "cors", | |
credentials: "include", | |
}); | |
const guildsData = await resp.json(); | |
return guildsData.map((s) => s.id); | |
} | |
async function supressEveryoneAndHere(serverIds) { | |
const actionBody = { guilds: {} }; | |
serverIds.forEach( | |
(id) => (actionBody.guilds[id] = { suppress_everyone: true }) | |
); | |
// Apply | |
fetch("https://discord.com/api/v9/users/@me/guilds/settings", { | |
headers, | |
body: JSON.stringify(actionBody), | |
method: "PATCH", | |
mode: "cors", | |
credentials: "include", | |
}); | |
console.log(`Disabled @everyone and @here for ${serverIds.length} servers!`); | |
} | |
async function muteAnnouncementChannels(serverIds, sleepBetween = 1000) { | |
const actionBody = { guilds: {} }; | |
const muteAction = {muted: true, mute_config: {selected_time_window: -1, end_time: null}} | |
for (const serverId of serverIds) { | |
// Initialize the structure for this serverId | |
if (!actionBody.guilds[serverId]) { | |
actionBody.guilds[serverId] = { channel_overrides: {} }; | |
} | |
const channelsResponse = await fetch( | |
`https://discord.com/api/v9/guilds/${serverId}/channels`, | |
{ | |
headers, | |
method: "GET", | |
mode: "cors", | |
credentials: "include", | |
} | |
); | |
const channelsData = await channelsResponse.json() | |
if (!channelsData) continue; | |
// 5 is announcment channel type | |
const announcementChannels = channelsData.filter((channel) => channel.type === 5); | |
for (const channel of announcementChannels) { | |
actionBody.guilds[serverId]["channel_overrides"][channel.id] = muteAction | |
console.log(`Add Muted announcement channel: ${channel.name} (${channel.id}) in server: ${serverId}`); | |
await new Promise(resolve => setTimeout(resolve, sleepBetween)) | |
} | |
} | |
// Apply | |
fetch("https://discord.com/api/v9/users/@me/guilds/settings", { | |
headers, | |
body: JSON.stringify(actionBody), | |
method: "PATCH", | |
mode: "cors", | |
credentials: "include", | |
}); | |
} | |
async function makeDiscordGreatAgain() { | |
const ids = await fetchserverIds() | |
await supressEveryoneAndHere(ids) | |
await muteAnnouncementChannels(ids) | |
} | |
makeDiscordGreatAgain() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment