Reputation: 33
I'm currently making a Discord bot using discord.py and I'm using a command tree to make slash commands, one of my files requires a file to be uploaded to the command, I know this is possible through discord as I have both seen it one before and done it in discord.js (I'm using python now as the bot links to something I have already made). But I can't seem to find anything on the internet or in the discord.py docs. Any clues as to how I might find this would be greatly appreciated, thanks in advance.
^Something like this is what I am talking about
Desired outcome: To have a slash command that a user is able to upload a file to
Tried so far: Reading the discord.py docs to see if it has a solution (it does not that I can find) and searching on the internet to see if there is anything even related to this (nothing that I have found).
Edit: I have found this that is related however it uses a different method of making slash commands and I have no method called "create_option". (The method I am using):
import discord
commandTree = discord.app_commands.CommandTree(bot)
@commandTree.command(name="command", description="Some command")
async def some_command(interaction):
print("Something")
Upvotes: 1
Views: 5968
Reputation: 5640
Annotate your argument with discord.Attachment
.
...
async def some_command(interaction, file: discord.Attachment):
...
Upvotes: 3