Discord.NET sending messages to one specific chann

2019-07-27 07:21发布

问题:

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 :\

回答1:

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. :/



回答2:

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