Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用python创建Discord Webhook_Python_Discord_Discord.py_Webhooks_Discord.py Rewrite - Fatal编程技术网

使用python创建Discord Webhook

使用python创建Discord Webhook,python,discord,discord.py,webhooks,discord.py-rewrite,Python,Discord,Discord.py,Webhooks,Discord.py Rewrite,使用python创建Discord Webhook 我最近正在用python开发一个discord机器人。我的discord机器人需要通过它发送消息 “不和谐网钩”。问题是我找不到一种方法来使用python自动创建一个不协调的webhook!有没有办法做到这一点 import discord client = discord.Client() @client.event async def on_message(message): if message.content == 'creat

使用python创建Discord Webhook 我最近正在用python开发一个discord机器人。我的discord机器人需要通过它发送消息 “不和谐网钩”。问题是我找不到一种方法来使用python自动创建一个不协调的webhook!有没有办法做到这一点

import discord
client = discord.Client()
@client.event
async def on_message(message):
    if message.content == 'createhook':
        #code to create a webhook in that current channel
client.run("token")

您需要一个
discord.TextChannel
对象。
在您的情况下,您可以使用
message.channel
获取消息对象的频道

要创建webhook,您需要执行
message.channel.create\u webhook(name=“mywebhook”)

您需要一个
discord.TextChannel
对象。
在您的情况下,您可以使用
message.channel
获取消息对象的频道

要创建webhook,您需要执行
message.channel.create\u webhook(name=“mywebhook”)