Is there any way if the status response code of CHANNEL_ID_1comes 200, then it should not send the message again in the same channel.
USERS_TOKEN = "TOKEN"
CHANNEL_ID_1 = "CHANNELID HERE"
CHANNEL_ID_2 = "CHANNELID HERE"
CHANNEL_ID_3 = "CHANNELID HERE"
CHANNEL_ID_4 = "CHANNELID HERE"
MESSAGE_1 = "msg 1 channel 1"
MESSAGE_2 = "msg 2 channel 2"
MESSAGE_3 = "msg 3 channel 3"
MESSAGE_4 = "msg 4 channel 4"
msgcount = "10"
def sendMessage(token, channel_id, message):
url = 'https://discord.com/api/v9/channels/{}/messages'.format(channel_id)
data = {"content": message}
header = {"authorization": token}
r = requests.post(url, data=data, headers=header)
print(r.status_code)
for i in range(int(msgcount)):
time.sleep(0.3)
sendMessage(USERS_TOKEN, CHANNEL_ID_1, MESSAGE_1)
sendMessage(USERS_TOKEN, CHANNEL_ID_2, MESSAGE_2)
sendMessage(USERS_TOKEN, CHANNEL_ID_3, MESSAGE_3)
sendMessage(USERS_TOKEN, CHANNEL_ID_4, MESSAGE_4)
plz modify that code its really helpful for me
Aucun commentaire:
Enregistrer un commentaire