使用 python 创建 Discord Webhook
Create Discord Webhook with python
使用 python 创建 Discord Webhook
我最近正在使用 python 开发一个不和谐的机器人。我的不和谐机器人需要通过它发送消息
“不和谐网络挂钩”。问题是我找不到使用 python 自动创建 discord 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")
https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.create_webhook
你需要一个 discord.TextChannel
对象。
在您的情况下,您可以使用 message.channel
获取消息对象的频道。 See here
要创建 Webhook,您需要执行 message.channel.create_webhook(name="mywebhook")
。
使用 python 创建 Discord Webhook 我最近正在使用 python 开发一个不和谐的机器人。我的不和谐机器人需要通过它发送消息 “不和谐网络挂钩”。问题是我找不到使用 python 自动创建 discord 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")
https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.create_webhook
你需要一个 discord.TextChannel
对象。
在您的情况下,您可以使用 message.channel
获取消息对象的频道。 See here
要创建 Webhook,您需要执行 message.channel.create_webhook(name="mywebhook")
。