I'm trying to make a python loop unitl CHANNEL_1, CHANNEL_2, CHANNEL_3, CHANNEL_4. request response code 200
import requests
import time
USERS_TOKEN = "TOKEN"
MDICT = {"CHANNEL_1": "message_1",
"CHANNEL_2": "message_2",
"CHANNEL_3": "message_3",
"CHANNEL_4": "message_4"
}
msgcount = 10
def sendMessage(token, channel_id, message):
url = f'https://discord.com/api/v9/channels/{channel_id}/messages'
data = {"content": message}
header = {"authorization": token}
with requests.Session() as session:
r = session.post(url, data=data, headers=header)
r.raise_for_status()
return r.status_code
while msgcount > 0 and MDICT:
time.sleep(0.3)
key = next(iter(MDICT.keys()))
if sendMessage(USERS_TOKEN, key, MDICT[key]) == 200:
del MDICT[key]
msgcount -= 1
Aucun commentaire:
Enregistrer un commentaire