【问题标题】:Sending text line-by-line to a discord webhook将文本逐行发送到不和谐的 webhook
【发布时间】:2021-06-03 12:43:39
【问题描述】:

我正在尝试通过 discord webhook 将 wordlist 中的文本逐行发送到 discord 频道。出于某种原因,下面的脚本仅发送单词列表中的最后一行。

from discord_webhook import DiscordWebhook

with open('wordlist.txt','r') as lines:    
    for line in lines:
                webhook = DiscordWebhook(url='webhookurlhere', content=lines.readline()

response = webhook.execute()

【问题讨论】:

    标签: discord.py webhooks


    【解决方案1】:
    from discord_webhook import DiscordWebhook
    
    file = open("wordlist.txt", 'r')
    lines = file.readlines()
    
    for line in lines:
        webhook= DiscordWebhook(url='myurl', content= line)
    
    response = webhook.exectute()
    file.close()
    

    您的 discordwebhook 调用似乎缺少右括号。我对文件的阅读结构也略有不同,对我来说更容易阅读。看看这是否适合你。

    【讨论】:

    • 嗯,好像还是不行。它只发送单词表的最后一行。这一定是线拼接的问题,因为脚本在将其输出到打印命令时会起作用。
    猜你喜欢
    • 2021-05-19
    • 2021-05-28
    • 2020-03-31
    • 2021-04-30
    • 2021-04-07
    • 2021-11-06
    • 2019-07-05
    • 2023-02-15
    • 2018-10-29
    相关资源
    最近更新 更多