How can I write messages in a specified channel?

时间:2019-05-31 11:47:44

标签: python discord discord.py discord.py-rewrite

In 0.16 I just said "client.get_channel("ID"), and could work with it. Now everything changed and when I try this, it says me "client" has no attribute "get_channel"...

So I tried "guild", because the API told me so on their Website. Iam going to put this in another command, but this shows my problem...

     @commands.command()
     async def test(self, ctx):
        guild = ctx.message.guild
        channel = guild.get_channel(channel_id="573422681983025193")
        await channel.send(content="Test")

I tried "id", in stead of "channel_id", no kind of "id", just client.get_channel, but nothing worked!

1 个答案:

答案 0 :(得分:0)

感谢Minn,他告诉了我答案! 您必须使用guild.get_channel(ID),对于字符串不使用“”。 我以为我尝试过,但这只是与client.get_channel(ID)一起使用,因此请使用

guild = ctx.message.guild
channel = guild.get_channel(ID)
await channel.send(content="Test"