【发布时间】:2021-10-15 19:37:49
【问题描述】:
我正在尝试获取用户附加的文件的 URL,以便稍后在我的代码中使用它,但我不太确定如何去做。
@client.command(pass_context=True)
async def readURL(ctx, url):
# Do something
参考资料:
【问题讨论】:
标签: discord discord.py
我正在尝试获取用户附加的文件的 URL,以便稍后在我的代码中使用它,但我不太确定如何去做。
@client.command(pass_context=True)
async def readURL(ctx, url):
# Do something
参考资料:
【问题讨论】:
标签: discord discord.py
如果我正确理解了这个问题,它会是这样的:
@client.command() # context is automatically passed in rewrite
async def readURL(ctx):
attachment = ctx.message.attachments[0] # gets first attachment that user
# sent along with command
print(attachment.url)
参考资料:
【讨论】: