I'm new to C#, and I am programming my first big project, a Discord bot. The idea is that the bot scans through comments, waiting for the word Cthulhu, and once someone says Cthulhu, the bot sends a message. However, in it's current state, it never stops sending messages. I suspect there's something wrong with my conditional, but have no idea how to fix it. How should I modify my code to fix this?
This is my code, I have the NuGet packages discord.net and discord.commands installed:
discord.MessageReceived += async (s, e) =>
{
if (e.Message.RawText.Contains("Cthulhu") )
await e.Channel.SendMessage("*Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn*");
};
Your bot is talking to itself :-D
Try this:
discord.MessageReceived += async (s, e) =>
{
if (!e.Message.IsAuthor && e.Message.RawText.Contains("Cthulhu") )
await e.Channel.SendMessage("*Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn*");
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With