我如何通过discord.py机器人将消息从网站发送到Discord频道

时间:2020-08-12 13:40:22

标签: python flask discord discord.py

所以我正在尝试为discord.py机器人制作仪表板 所以我做了一个页面,我将在其中输入我的姓名,电子邮件和电话号码,单击提交后,将打开另一个页面,在该页面中我将看到值 所以我想将discord.py机器人连接到它,这样当我单击“提交”时它将发送嵌入到特定频道 我不知道该怎么做,我尝试了很多事情,但没用

from flask import Flask, render_template, redirect, url_for, request


import discord
from dhooks import Webhook, Embed
from discord.ext import commands, tasks



app = Flask(__name__)
@app.route('/yami/home/posts')
def posts():
   return render_template('posts.html')

@app.route('/verified', methods = ['POST', 'GET'])
async def verified():
    if request.method == "POST":
        result = request.form
        channel_entry = 694563592518893601
        msg_entry = 'test'


        channel = client.get_channel(channel_entry)
        await channel.send(msg_entry)

        return render_template("verified.html", result = result) 
<!--posts-->
{% extends "base.html" %}
<!--HEAD-->
{% block head %}
<title>TEST posts 1</title>

{% endblock %}
<!--HEAD end-->

<!--STYLE-->
{% block style %} {% endblock %}
<!--STYLE end-->

<!--BODY-->
{% block body %}
<div class="center">
    <h1>This is posts</h1>

     <div class="side">
         <a href="index">Click to go to index</a><br>
         <a href="home">click to go to home</a><br>
         <a href="new">Click to go to new</a><br>
           <a href="/result">click to go to result</a><br>
    <a href="/student">click to go to student</a><br>

          <a href="verified">click to go to verified</a>
     </div>
</div>
{% for s in stuff1%}
<h1>{{s.title}}</h1>
<p>{{s.content}}</p>
{% endfor %}
<form action="/verified" method="POST">
    <div class="side">
        <h3>Sign up</h3>

    Author:<input type="text" name="author">
        Email:<input type="email" name="email">
        Phone no.:<input type="number" name="phone no">
    Submit:<input type="submit" value="submit">
    </div>



</form>
{% endblock %}
<!--BODY end-->
<!--verified-->
{% extends "base.html" %}
<!--HEAD-->
{% block head %}
<title>TEST posts 1</title>

{% endblock %}
<!--HEAD end-->

<!--STYLE-->

{% block style %} {% endblock %}
<!--STYLE end-->

<!--BODY-->
{% block body %}
<div class="side">
   <a href="/yami/home/index">Click to go to index</a><br>
    <a href="/yami/home/home">click to go to home</a><br>
    <a href="/yami/home/new">Click to go to new</a><br>
     <a href="/yami/home/posts">click to go to posts</a><br>
      <a href="/result">click to go to result</a><br>
    <a href="/student">click to go to student</a><br>
</div>
{% for key, value in result.items() %}
<h1><ins>{{ key }} :</ins></h1>
<h3>{{ value }} </h3>
{% endfor %}



{% endblock %}

这些是与2页相关的代码

0 个答案:

没有答案
相关问题