vb.net Discord.NET 将消息发送到一台特定服务器中的一个特定通道
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47884627/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Discord.NET sending messages to one specific channel in one specific server
提问by Mark
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 :\
据我所知,这不是这样做的方法,但我不知道还有什么地方可以检查:\
回答by Mark
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. :/
很抱歉在答案非常简单时寻求帮助。:/
回答by jim johnsson
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
当获取不需要获取公会的频道时,所有频道都在您的客户端内,因此 discord.GetTextChannel("id").SendMessageAsync("message") 就足够了

