Reputation: 29
I want to shorten these codes. The x part is a different message and the y part is the token of a different account. It has to be different each time. For example, after doing it, it goes to the next account and writes the next message.
import requests
payloud = {
'content': "x"
}
header = {
'authorization': 'y'
}
r = requests.post("https://discord.com/api/v9/channels/1007038944707346502/messages", data=payloud, headers=header)
i tried creating a text document and using the contents but i couldn't
Upvotes: 0
Views: 42
Reputation: 298
Use a list of dicts:
import requests
url = "https://discord.com/api/v9/channels/1007038944707346502/messages"
lst = [{'payloud' : {'content': "x"},'header' : {'authorization': 'y'}}, {'payloud' : {'content': "z"},'header' : {'authorization': 'xy'}}...]
for i in lst:
r = requests.post(url, data=i['payloud'], headers=i['header'])
Upvotes: 1