【问题标题】:Getting the URL of an attachment in Discord.py在 Discord.py 中获取附件的 URL
【发布时间】:2021-10-15 19:37:49
【问题描述】:

我正在尝试获取用户附加的文件的 URL,以便稍后在我的代码中使用它,但我不太确定如何去做。

@client.command(pass_context=True)
async def readURL(ctx, url):
    # Do something

参考资料:

【问题讨论】:

    标签: discord discord.py


    【解决方案1】:

    如果我正确理解了这个问题,它会是这样的:

    @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)
    

    参考资料:

    【讨论】:

    • 成功了!谢谢,被选为解决方案:)
    • 太棒了!快乐编码:')
    猜你喜欢
    • 1970-01-01
    • 2023-01-09
    • 2011-10-11
    • 2020-10-12
    • 2018-05-07
    • 2021-04-23
    • 1970-01-01
    • 2015-02-26
    • 2021-10-28
    相关资源
    最近更新 更多