3

I'm trying to use a bot to download discord image attachments but every request is met with a 403. Here's the code,

import discord
import urllib.request

print('Starting')

bot = discord.Client()

@bot.event
async def on_ready():
    print('Bot is ready!')

@bot.event
async def on_message(message):
    if not message.attachments:
        print(f'{message.author}: {message.content}')
    else:
        attachment = message.attachments[0]
        print(f'{attachment.url}')
        urllib.request.urlretrieve(attachment.url,f'{attachment.filename}.jpg')

bot.run('...')

I am completely lost please help thank you.

sprice4
  • 43
  • 2
  • 1
    Http code 403 is telling you that access to the requested url is forbidden. Are you sure you have access to that content? – Glyphack Mar 10 '20 at 20:54

0 Answers0