久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <legend id='ptiPF'><style id='ptiPF'><dir id='ptiPF'><q id='ptiPF'></q></dir></style></legend>
      <tfoot id='ptiPF'></tfoot>

      <small id='ptiPF'></small><noframes id='ptiPF'>

      • <bdo id='ptiPF'></bdo><ul id='ptiPF'></ul>
      <i id='ptiPF'><tr id='ptiPF'><dt id='ptiPF'><q id='ptiPF'><span id='ptiPF'><b id='ptiPF'><form id='ptiPF'><ins id='ptiPF'></ins><ul id='ptiPF'></ul><sub id='ptiPF'></sub></form><legend id='ptiPF'></legend><bdo id='ptiPF'><pre id='ptiPF'><center id='ptiPF'></center></pre></bdo></b><th id='ptiPF'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ptiPF'><tfoot id='ptiPF'></tfoot><dl id='ptiPF'><fieldset id='ptiPF'></fieldset></dl></div>

        Python + Flask + Discord:如何通過flask端點通過discord發

        Python + Flask + Discord: How to send a message through discord through a flask endpoint?(Python + Flask + Discord:如何通過flask端點通過discord發送消息?)

            <tbody id='VNk16'></tbody>

            <tfoot id='VNk16'></tfoot>
                • <bdo id='VNk16'></bdo><ul id='VNk16'></ul>
                  <legend id='VNk16'><style id='VNk16'><dir id='VNk16'><q id='VNk16'></q></dir></style></legend>

                  <small id='VNk16'></small><noframes id='VNk16'>

                  <i id='VNk16'><tr id='VNk16'><dt id='VNk16'><q id='VNk16'><span id='VNk16'><b id='VNk16'><form id='VNk16'><ins id='VNk16'></ins><ul id='VNk16'></ul><sub id='VNk16'></sub></form><legend id='VNk16'></legend><bdo id='VNk16'><pre id='VNk16'><center id='VNk16'></center></pre></bdo></b><th id='VNk16'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='VNk16'><tfoot id='VNk16'></tfoot><dl id='VNk16'><fieldset id='VNk16'></fieldset></dl></div>

                  本文介紹了Python + Flask + Discord:如何通過flask端點通過discord發送消息?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試發送一條不和諧的消息,通過 Flask 端點激活

                  I'm trying to send a message with discord, activated through a Flask endpoint

                  我在調用 http://127.0.0.1:5000/send

                  RuntimeError: There is no current event loop in thread 'Thread-4'.
                  

                  我有以下(最少的)代碼

                  I have the following (minimal) code

                  import discord
                  from flask import Flask, jsonify
                  
                  async def my_background_task():
                  
                    for message in ['a', 'b']:
                      await client.wait_until_ready()
                      channel = client.get_channel(CHANNEL_ID)
                      await channel.send(message)
                  
                    await client.close() 
                  
                  def sendMessages():
                    client = discord.Client()
                    client.loop.create_task(my_background_task())
                    client.run('SECRET')
                  
                  app = Flask(__name__)
                  
                  
                  @app.route('/send')
                  def send():
                    sendMessages()
                  

                  推薦答案

                  也許您應該考慮使用 webhook 而不是機器人.這是一個簡單的示例,您應該對其實現燒瓶.

                  Maybe you should consider using webhooks instead of a bot. Here is a simple example you should implement flask to it.

                  import requests #dependency
                  
                  url = "<your url>" #webhook url, from here: https://i.imgur.com/aT3AThK.png
                  
                  data = {}
                  #for all params, see https://discordapp.com/developers/docs/resources/webhook#execute-webhook
                  data["content"] = "message content"
                  data["username"] = "custom username"
                  
                  #leave this out if you dont want an embed
                  data["embeds"] = []
                  embed = {}
                  #for all params, see https://discordapp.com/developers/docs/resources/channel#embed-object
                  embed["description"] = "text in embed"
                  embed["title"] = "embed title"
                  data["embeds"].append(embed)
                  
                  result = requests.post(url, json=data, headers={"Content-Type": "application/json"})
                  
                  try:
                      result.raise_for_status()
                  except requests.exceptions.HTTPError as err:
                      print(err)
                  else:
                      print("Payload delivered successfully, code {}.".format(result.status_code))
                  
                  #result: https://i.imgur.com/DRqXQzA.png
                  

                  這篇關于Python + Flask + Discord:如何通過flask端點通過discord發送消息?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to make a discord bot that gives roles in Python?(如何制作一個在 Python 中提供角色的不和諧機器人?)
                  Discord bot isn#39;t responding to commands(Discord 機器人沒有響應命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關于我嗎?Discord 機器人的功能?(不和諧.py))
                  message.channel.id Discord PY(message.channel.id Discord PY)
                  How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機器人?)
                  discord.py - Automaticaly Change an Role Color(discord.py - 自動更改角色顏色)

                      <bdo id='0VzLO'></bdo><ul id='0VzLO'></ul>

                            <tbody id='0VzLO'></tbody>
                        1. <small id='0VzLO'></small><noframes id='0VzLO'>

                          <legend id='0VzLO'><style id='0VzLO'><dir id='0VzLO'><q id='0VzLO'></q></dir></style></legend>
                        2. <tfoot id='0VzLO'></tfoot>

                          • <i id='0VzLO'><tr id='0VzLO'><dt id='0VzLO'><q id='0VzLO'><span id='0VzLO'><b id='0VzLO'><form id='0VzLO'><ins id='0VzLO'></ins><ul id='0VzLO'></ul><sub id='0VzLO'></sub></form><legend id='0VzLO'></legend><bdo id='0VzLO'><pre id='0VzLO'><center id='0VzLO'></center></pre></bdo></b><th id='0VzLO'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='0VzLO'><tfoot id='0VzLO'></tfoot><dl id='0VzLO'><fieldset id='0VzLO'></fieldset></dl></div>
                          • 主站蜘蛛池模板: 亚洲乱码一区二区三区在线观看 | 久草视频观看 | 视频一区在线 | 欧美片网站免费 | 国产一区二区三区色淫影院 | 美日韩免费视频 | 中文字幕一区二区三区不卡在线 | 日朝毛片| 99亚洲精品| www.日韩在线| 亚洲免费视频在线观看 | 在线观看免费毛片 | 人妖一区 | 国产一二三区免费视频 | 欧美精品乱码99久久影院 | 中文字幕高清在线 | 日本中文字幕日韩精品免费 | 91xxx在线观看| 色吊丝2288sds中文字幕 | 日韩最新网站 | 丝袜毛片| 国产视频观看 | 北条麻妃一区二区三区在线视频 | 日韩看片 | 久久精品1 | 免费同性女女aaa免费网站 | 91精品久久久久久久久久入口 | 国产成人精品高清久久 | 亚洲一区二区三区高清 | 综合国产第二页 | 毛片免费看 | 亚洲精品久久久久久久久久久久久 | 国产精品激情小视频 | 91综合网 | 国产精品毛片一区二区三区 | 欧美天堂在线观看 | 欧美久久影院 | 国产成人亚洲精品 | 亚洲欧洲综合av | 天天搞天天操 | 久草免费在线视频 |