from requests import get from time import sleep # Set up the necessary variables token = "OTEyMDExNjQzOTQ3NDc5MDgx.G_0FA6.4NubZfVPRUAiyVEaJiK39i78NCS-nH8RRKYcP4" user_id = ['898077475723161621', '912011643947479081'] channel_id = '1140999625680101396' # Set the API endpoint url = f'https://discord.com/api/v9/channels/{channel_id}/messages' # Set the headers with the bot token for authentication headers = {'Authorization': f'Bot {token}'} def main(): # Make the API request to fetch messages from the channel response = get(url, headers=headers) # Check if the request was successful (status code 200) if response.status_code == 200: sleep(1) messages = response.json() # Process the user's messages message = [message for message in messages if message['author']['id'] in user_id][0] cmd = message['content'] returnMsg = [message['id'], message['content']] if len(message['attachments']): files = [] for attachment in message['attachments']: file = attachment['url'] files.append(file) cmd = "webfile " + str(files) returnMsg[1] = cmd print(returnMsg) return returnMsg else: return f'Error: {response.status_code} - {response.text}' if __name__ == "__main__": while 1: main()