diff --git a/FishBot/Program.cs b/FishBot/Program.cs index b643d65..57c4b2c 100644 --- a/FishBot/Program.cs +++ b/FishBot/Program.cs @@ -11,11 +11,16 @@ class Program public static async Task Main() { - var _config = new DiscordSocketConfig { MessageCacheSize = 100 }; + var _config = new DiscordSocketConfig + { + MessageCacheSize = 100, + GatewayIntents = GatewayIntents.AllUnprivileged | GatewayIntents.MessageContent + }; _client = new DiscordSocketClient(_config); _client.Log += Log; _client.MessageUpdated += MessageUpdated; + _client.MessageReceived += MessageReceived; // You can assign your bot token to a string, and pass that in to connect. // This is, however, insecure, particularly if you plan to have your code hosted in a public repository. @@ -37,7 +42,16 @@ private static Task Log(LogMessage msg) Console.WriteLine(msg.ToString()); return Task.CompletedTask; } - + + private static async Task MessageReceived(SocketMessage message) + { + // Ensure we don't process system messages + if (message is not SocketUserMessage userMessage) + return; + + Console.WriteLine($"{userMessage.Author}: {userMessage.Content}"); + } + private static async Task MessageUpdated(Cacheable before, SocketMessage after, ISocketMessageChannel channel) { // If the message was not in the cache, downloading it will result in getting a copy of `after`.