【发布时间】:2018-02-27 09:43:19
【问题描述】:
首先,我是新手。我想编写一个 Discord-bot 函数,它在用户在特定频道中发送的每条消息的开头查找一个字符,如果该机器人连续两次没有找到该字符,它就会起作用。
string neededCharacter = ">";
if (Dont.FindCharacterTwoTimesInARow.Equals(neededCharacter)) //If you don't find neededCharacter in sent messages two times in a row
{
if (ChannelName.Equal("channel_name")) //look for the specific channel
{
//send message to the channel, stating that the character hasn't been found
await Context.Channel.SendMessageAsync("'>' not found two times in a row");
}
}
请注意,ChannelName.Equal("channel_text") 和 Dont.FindCharacterTwoTimesInARow.Equals(neededCharacter) 显然不是真实的东西,它们只是“展示”我想在那里做的事情。
如果有人能告诉我这样的事情是如何可能的,那就太好了。提前致谢。
【问题讨论】:
-
你尝试过做什么?展示你的尝试并解释问题出在哪里
-
基本上,我试图查找频道的名称,但在代码中找不到任何实际执行此操作的方法。对我来说,“大问题”是找到实际频道并仅在其中搜索文本。
-
您可能想再看一下
Context.Channel对象,您在其中的代码中使用。
标签: c# discord discord.net