Discord.NET sending messages to one specific chann

2019-07-27 07:04发布

So I'm trying to send a message to a specific channel, but I've been looking and found I can't see any way I can do that. I might be doing something wrong or I'm looking in the wrong area, I've looked on Google and couldn't find an answer. This is my code when trying to find it.

     discord.GetGuild("serverid").GetChannel("Channelid")

As far as I can see, this is not the way to do it, but I don't know where else to check :\

2条回答
祖国的老花朵
2楼-- · 2019-07-27 07:21

when getting the channel you dont need to get the guild, all channels is inside your client so discord.GetTextChannel("id").SendMessageAsync("message") would be enough

查看更多
一夜七次
3楼-- · 2019-07-27 07:38

Actually, I kinda feel stupid after realizing this, In my code previously, I was making the program try and find a channel, when what I actually needed to do was find a text channel, like so:

    discord.GetGuild("serverid").GetTextChannel("Channelid").SendMessageAsync(
    "Message")

So sorry for asking for help when the answer was really simple. :/

查看更多
登录 后发表回答