gpt4 book ai didi

python - 使用 python 创建 Discord Webhook

转载 作者:行者123 更新时间:2023-12-02 02:39:08 25 4
gpt4 key购买 nike

使用 python 创建 Discord Webhook我最近正在用 python 开发一个不和谐的机器人。我的不和谐机器人需要通过哪里发送消息“DISCORD WEBHOOK”。问题是我找不到使用 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")

最佳答案

https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.create_webhook

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

要创建 Webhook,您需要执行 message.channel.create_webhook(name="mywebhook")

关于python - 使用 python 创建 Discord Webhook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63895517/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com