【问题标题】:discord.py, sending a message in all channels with a webhookdiscord.py,使用 webhook 在所有通道中发送消息
【发布时间】:2021-06-06 16:35:35
【问题描述】:

我想为我的私人服务器创建一个命令,在所有公会频道中创建 webhook 并让他们发送消息,我已经尝试过这样:

@client.command()
async def allchannel(ctx):
  for channel in ctx.guild.channels:
    webhook = discord.utils.get(await ctx.channel.webhooks())
    if not webhook:
      webhook = await ctx.channel.create_webhook("Test")
      await webhook.send(content="Hello")

但它说:discord.ext.commands.errors.CommandInvokeError:命令引发异常:TypeError:create_webhook() 采用 1 个位置参数,但给出了 2 个

【问题讨论】:

    标签: python discord discord.py webhooks


    【解决方案1】:

    好的,我自己解决了这个问题,如果你想知道我是怎么做到的,我只需要这样说:

    except AttributeError:
                pass
    

    【讨论】:

      猜你喜欢
      • 2021-05-03
      • 2021-02-19
      • 1970-01-01
      • 2021-04-12
      • 1970-01-01
      • 2021-03-24
      • 1970-01-01
      • 1970-01-01
      • 2021-04-04
      相关资源
      最近更新 更多