aboutsummaryrefslogtreecommitdiffstats
path: root/community/disc.py
blob: 8cc5aebb89450fdde221198059ac531a124cb21d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
import requests
from dotenv import load_dotenv

load_dotenv()

def fetch_messages(channel_id: str):
    url = f"https://discord.com/api/v9/channels/{channel_id}/messages?limit=50"
    headers = {
        "accept-encoding": "gzip, deflate, br, zstd",
        "accept-language": "en-GB",
        "authorization": os.getenv("DISCORD_AUTHORIZATION"),  # Replace with your real token
        "priority": "u=1, i",
        "sec-ch-ua": '"Not:A-Brand";v="24", "Chromium";v="134"',
        "sec-ch-ua-mobile": "?0",
        "sec-ch-ua-platform": '"Linux"',
        "sec-fetch-dest": "empty",
        "sec-fetch-mode": "cors",
        "sec-fetch-site": "same-origin",
        "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36",
        "x-debug-options": "bugReporterEnabled",
        "x-discord-locale": "en-US",
        "x-discord-timezone": "America/Vancouver",
    }
    response = requests.get(url, headers=headers)
    return response.json()
    if response.ok:
        print(f"Failed to fetch: {response.status_code} - {response.text}")
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage