Get and Send message from and to specific channel and direct message
See original GitHub issueHello Sorry if I write this to bad section but I didn’t see support menu. So my question is how can I send and get messages from and to specific channel? Other is, how can I get direct message and send to direct message? I try to create a chat bot and my plan is that if someone write a direct message to chatbot then the chat bot answer to message in the same direct message. Same with channel. For example I create a channel “test” channel and someone write something in “test” channel then the bot answer to “test” channel.
I tried somehow create a solution to this, but the chat bot get messages from everywhere not from specific parts.
My code is this: `
client.MessageReceived += async (s, e) =>
{
if (!e.Message.IsAuthor)
{
var responseString = await httpclient.GetStringAsync("http://api.program-o.com/v2/chatbot/?" + e.Message.Text + "&convo_id=exampleusage_1231232&format=json");
Botvalasza botvalasza = JsonConvert.DeserializeObject<Botvalasza>(responseString);
Console.WriteLine(botvalasza.botsay);
var channel = e.Server.FindChannels("test", ChannelType.Text).FirstOrDefault();
await channel.SendMessage(botvalasza.botsay);
}
};
`
This code send to specific channel answers but not to direct messages and this get all messages from all channels and direct messages. Thank you in advance for your answer 😃
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:9 (4 by maintainers)
Top GitHub Comments
For anyone who arrived here from Google like me:
I managed to check if a message is a Direct Message casting the source message channel to IDMChannel. An example:
Ok, I found a solution. 😄 If someone want same thing as I then here is the solution.
If you want check if the message come via DM then you can use this:
If the message come via specific channel then here is the code: