MCPcopy Index your code
hub / github.com/ShufflePerson/Discord_CDN

github.com/ShufflePerson/Discord_CDN @2.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release 2.2 ↗ · + Follow
19 symbols 34 edges 14 files 5 documented · 26%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Discord

Discord CDN V2

Updates any old/expired Discord download links.

Graph

Usage

There are two ways to use the HTTP server

Way 1

Simply paste the Discord URL at the end of your server URL

http://localhost/https://cdn.discordapp.com/attachments/763509665585561610/1216965708911480923/image.png

Way 2

Replace the cdn.discord.app.com with your URL. Make sure to change HTTPS to HTTP unless you have configured HTTPS through something like CloudFlare.

http://localhost/attachments/763509665585561610/1216965708911480923/image.png

Using as a Library

If you wish to use Discord CDN as a library, check the code example below.

You may also check src/server.ts to see how the HTTP server uses it.

import { Discord, getConfig } from "PATH_TO_DISCORD_CDN"

//getConfig will parse the config from .env
//if you wish to pass your own config object, check the `src/Types/IConfig.ts` interface

async function dev() {
    try {
        let config = await getConfig();
        let discord = new Discord(config);
        let link = await discord.fetchLatestLink("https://cdn.discordapp.com/attachments/763509665585561610/1216965708911480923/image.png?ex=")
        console.log(link);
    } catch (ex) {
        console.error(ex);
    }
}

dev();

Installation and Setup

Download the repo

git clone https://github.com/ShufflePerson/Discord_CDN.git
cd Discord_CDN

OR

Download the repo as a zip and extract it to a folder.

Setup Environment file ( .env )

Fill the values in the .env.example and rename .env.example to simply .env

  • TOKEN
  • A Discord Account Token, used for fetching the link
  • FALLBACK
  • If Discord removes the endpoint for fetching a non-expired link, fallback to the V1 lookup.
  • PORT
  • Specifies what port the HTTP server will be running on.

How to get your token

  1. Open Discord on your Browser.
  2. Open the Dev Tools ( Inspect Element )
  3. Go to the Console Tab and paste in the following command
  4. console.log((webpackChunkdiscord_app.push([[''],{},e=>{m=[];for(let c in e.c)m.push(e.c[c])}]),m).find(m=>m?.exports?.default?.getToken!==void 0).exports.default.getToken());
  5. Copy the output and set it in the .env file. (e.g TOKEN=PASTE_TOKEN_HERE)

Yarn

Install packages

yarn install

Start the server

yarn pnpify tsc
yarn node ./dist/server.js

NPM

Install packages

npm run setup

Start the server

This will also recompile the code.

npm run start

Contact

You may contact me on my Discord: _.shuffle._

Extension points exported contracts — how you extend this code

IConfig (Interface)
(no doc)
src/Types/IConfig.ts
IRefreshUrlsRes (Interface)
(no doc)
src/Discord/Types/IRefreshUrlsRes.ts
ILinkData (Interface)
(no doc)
src/Discord/Types/ILinkData.ts
IParsedLink (Interface)
(no doc)
src/Discord/Types/IParsedLink.ts

Core symbols most depended-on inside this repo

getConfig
called by 2
src/config.ts
fetchLatestLink
called by 2
src/Discord/Discord.ts
dev
called by 1
src/dev.ts
initServer
called by 1
src/server.ts
getHTTPConfig
called by 1
src/Discord/Discord.ts
staticVerifyToken
called by 1
src/Discord/Utils/VerifyToken.ts
VerifyToken
called by 1
src/Discord/Utils/VerifyToken.ts
ParseLink
called by 1
src/Discord/Utils/ParseLink.ts

Shape

Function 8
Interface 4
Method 3
Class 2
Enum 2

Languages

TypeScript100%

Modules by API surface

src/Discord/Discord.ts5 symbols
src/Discord/Utils/VerifyToken.ts2 symbols
src/Discord/Utils/GetUTF8Base64.ts2 symbols
src/server.ts1 symbols
src/dev.ts1 symbols
src/config.ts1 symbols
src/Types/IConfig.ts1 symbols
src/Discord/Utils/ParseLink.ts1 symbols
src/Discord/Types/IRefreshUrlsRes.ts1 symbols
src/Discord/Types/IParsedLink.ts1 symbols
src/Discord/Types/ILinkData.ts1 symbols
src/Discord/Types/ETokenIssue.ts1 symbols

For agents

$ claude mcp add Discord_CDN \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact