

# do make sure to check that before saving # do note, attachment can be of ANY type, a file, an image, # or if you want to save the image locally on your machine, # if you want to save url, use attachment.url to get the # person who executed the command and that message.attachments is not anĪttachment = attachment_message.attachments # the check keyword argument checks if the message was sent by the same Now, your code would look something like def setup(ctx):Īttachment_message = await client.wait_for('message', check= lambda m: m.author = ctx.author and m.attachments) Here is an example of Inde圎rror > empty_list = If you try to index a list to an index where an element is not present in, it throws an Inde圎rror. Message.attachments returns a List (list of Attachment objects found in the message) I am still not sure what the msgid in there is for, but to wait for the image to be sent, you would need to use another wait_for with a check, that looks out if the message contains an attachment. When you do, you are checking for attachments on the message that invoked the command of the bot. for example, if your user did !setup, where ! is the prefix for your command (assuming), that message is the ctx.message


The above exception was the direct cause of the following exception:įile "/home/runner/WelcomeBot/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invokeįile "/home/runner/WelcomeBot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invokeįile "/home/runner/WelcomeBot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrappedĭ.CommandInvokeError: Command raised an exception: AttributeError: 'Message' object has no attribute 'attachment'Īfter fixing imageUsed I get an index error Ignoring exception in command setupwelcome:ĭ.CommandInvokeError: Command raised an exception: Inde圎rror: list index out of rangeĬtx.message is a Message object created from the message that invoked the command. ImageUsed = await ĪttributeError: 'Message' object has no attribute 'attachment' Ignoring exception in command setupwelcome:įile "/home/runner/WelcomeBot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped If () = 'y':Īwait ctx.send("Upload the image you want to use:") WelcomeMessage = await client.wait_for("message")Īwait ctx.send("Do you want to include an image in your welcome message?")ĭecisionMessage = await client.wait_for("message") import discordĬlient = commands.Bot(command_prefix = help='Sets up the welcome message.')Īwait ctx.send("Enter welcome message here (If it is a multiline message, write the whole welcome message on a text editor and paste it on discord.") So, I have been trying to figure out how to download an attachment but I can't seem to figure out how.
