【问题标题】:Create a channel on a discord server with webhook使用 webhook 在不和谐服务器上创建频道
【发布时间】:2019-08-22 22:58:48
【问题描述】:

我正在使用 discord webhook api 向我的 discord 服务器频道发送消息。在一个新用例中,我想创建一个带有 webhook 的新频道。不幸的是,我找不到任何 API 可以做到这一点。我在这里阅读了整个文档:https://discordapp.com/developers/docs/resources/webhook#create-webhook

这甚至可能吗?我看到了允许它的不和谐机器人的方法 - 因此我有点认为它也应该可以通过 webhook 实现。

【问题讨论】:

    标签: api discord webhooks


    【解决方案1】:

    我认为 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")
    

    您可以找到文档here,您可以创建您的机器人here

    【讨论】:

      猜你喜欢
      • 2021-11-23
      • 1970-01-01
      • 2020-04-04
      • 2020-09-06
      • 2021-08-13
      • 2020-12-28
      • 2020-08-29
      • 2022-01-07
      • 2021-10-25
      相关资源
      最近更新 更多