discord.py,使用 webhook 在所有频道中发送消息

时间:2021-03-08 19:21:52

标签: python discord discord.py webhooks

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

@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:Command引发异常:TypeError:create_webhook()需要1个位置参数,但给出了2个

1 个答案:

答案 0 :(得分:0)

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

except AttributeError:
            pass