api - 使用 webhook 在不和谐服务器上创建频道
问题描述
我正在使用 discord webhook api 将消息发送到我的 discord 服务器频道。在一个新的用例中,我想创建一个带有 webhook 的新频道。不幸的是,我找不到任何 API 可以做到这一点。我在这里阅读了整个文档:https ://discordapp.com/developers/docs/resources/webhook#create-webhook
这甚至可能吗?我看到了允许它的不和谐机器人的方法 - 因此我有点认为它也应该可以通过 webhook 实现。
解决方案
我认为 Discord webhook 仅用于发送消息,仅此而已,如果您不想手动创建频道,您可能必须使用机器人来创建频道。
我认为仅在 rewrite 分支上支持通过 discord.py API 创建 webhook
安装 discord.py-rewrite
pip install git+https://github.com/Rapptz/discord.py@rewrite
import discord
from discord.ext.commands import Bot
bot=Bot(command_prefix='.')
@bot.event
async def on_ready():
print(bot.user.name)
@bot.command()
async def chan(msg):
chan=await msg.guild.create_text_channel(name='New text')
web=await chan.create_webhook(name='New web')
print(web.url)
bot.run("YOUr bot token here")
推荐阅读
- python-3.x - 否则:不能在 jupyter notebook python 3 中工作
- visual-studio - 为什么 Visual Studio 会这样显示 O?
- firefox - 如何让鼠标按钮 4 / 5(浏览器后退/浏览器前进)在 Firefox 中工作?
- c# - 在 C# 中成功 RSA 加密数据
- r - 有没有办法“宏”输入多个值来优化 R?
- java - 如何在java中创建一个抛出异常的方法?
- linux - LanguageTool Java 应用程序作为 systemd 服务运行。`--languagemodel` 参数被忽略
- wpf - WPF:Prism Window XAML 的 Topmost 属性的 DataTrigger
- raku - 乐中的有理数
- python - 如何在多列内切片?