Python 如何使用discord.py中的id获取频道?

Python 如何使用discord.py中的id获取频道?,python,python-3.x,discord,discord.py,Python,Python 3.x,Discord,Discord.py,我有一个命令,它发送一个带有用户提供参数的嵌入。其中一个参数是通道。我已将频道剥离到ID,但get_channel表示它缺少1个必需的位置参数:“ID”。以下是我当前的代码: @commands.command(description='Send an embed message with Title, Colour, Footer and Field customization.') async def embed(self, ctx, *, args=None): if ar

我有一个命令,它发送一个带有用户提供参数的嵌入。其中一个参数是通道。我已将频道剥离到ID,但get_channel表示它缺少1个必需的位置参数:“ID”。以下是我当前的代码:

  @commands.command(description='Send an embed message with Title, Colour, Footer and Field customization.')
  async def embed(self, ctx, *, args=None):
    if args == None:
      #code here
    else:
      embedConfig=args.split(" | ")
      if (len(embedConfig)-1) > 4:
        await ctx.send("Too many arguments!")
      else:
        embed=discord.Embed(title=embedConfig[1], description=embedConfig[3], color=int(embedConfig[2][1:],16))
        embed.set_footer(text=embedConfig[4])
        embed.timestamp = datetime.now()
        embedConfig[0] = embedConfig[0].lstrip("<#")
        print(embedConfig[0])
        embedConfig[0] = int(embedConfig[0].rstrip(">"))
        print(embedConfig[0])
        await ctx.send(embedConfig)
        channel = discord.Client.get_channel(embedConfig[0])
        await channel.send(embed=embed)
@commands.command(description='发送带有标题、颜色、页脚和字段自定义的嵌入消息!')
异步def嵌入(self,ctx,*,args=None):
如果args==无:
#代码在这里
其他:
embedConfig=args.split(“|”)
如果(len(embedConfig)-1)>4:
等待ctx.send(“参数太多!”)
其他:
embed=discord.embed(title=embedConfig[1],description=embedConfig[3],color=int(embedConfig[2][1:],16))
embed.set_页脚(text=embedConfig[4])
embed.timestamp=datetime.now()
embedConfig[0]=embedConfig[0].lstrip(“”)
打印(嵌入配置[0])
等待ctx.send(embedConfig)
通道=discord.Client.get_通道(embedConfig[0])
等待通道发送(嵌入=嵌入)

我将命令扩展与discord.py-rewrite一起使用,上面的命令位于cog中。谢谢

您指的是类本身,而不是实例

channel=self.client.get_channel(embedConfig[0])#或'self.bot',不管您在uu init_u方法中如何命名它

您指的是类本身,而不是实例

channel=self.client.get_channel(embedConfig[0])#或'self.bot',不管您在uu init_u方法中如何命名它