【问题标题】:Python discord Bot coping messages from one user and sending them in a webhookPython discord Bot 处理来自一个用户的消息并在 webhook 中发送它们
【发布时间】:2021-04-21 10:48:32
【问题描述】:

所以我尝试编写一个机器人来复制来自一个用户的消息并通过 webhook 将它们发送到不同的服务器,但我在处理消息时卡住了,找不到任何答案。

    import discord
    import os
    import requests
    import json
    from dhooks import Webhook, file
    
    
    hook = Webhook("WEBHOOK HERE")
    
    
    client = discord.Client()
    
    @client.event
    async def on_ready():
      print('Logged in as {0.user}'.format(client))
    
    
    async def on_message(message):
      if message.author.id == "ID HERE":
        hook.send(content = "MESSAGE HERE", username = "Secound", avatar_url = "https://i.imgur.com/Kg5IIib.png")
    
       
    
    client.run(os.getenv('TOKEN'))

【问题讨论】:

    标签: python discord bots discord.py webhooks


    【解决方案1】:

    discord.Message 具有引用消息内容的属性content

    content = message.content
    # i.e `Hello world`
    

    参考:

    【讨论】:

      猜你喜欢
      • 2022-01-05
      • 2020-12-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-14
      • 2020-08-17
      • 1970-01-01
      • 2018-07-24
      • 2020-03-20
      相关资源
      最近更新 更多