1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import os
import requests
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()
|