async Task OnMessageReceivedAsync(ISocketMessageChannel channel, SocketUser user, string content) { Log.Info($"input: \"{content}\" by user: {user.Username} in channel: {channel.Name}"); var receivedMessage = content.ToLower(); if (receivedMessage.Contains("check")) { if (_identityLinker.TryGetSteamId(user.Id, out var linkedSteamId)) { var linkedPlayerName = MySession.Static.Players.TryGetIdentityNameFromSteamId(linkedSteamId); await channel.MentionAsync(user.Id, $"Your Discord user is linked to \"{linkedPlayerName}\"."); _chatManager.SendMessage("Alert", linkedSteamId, $"You're linked to \"{user.Username}\"."); } else { await channel.MentionAsync(user.Id, "Your Discord user is not linked to any in-game players. Try `!alert link` in game."); } return; } if (int.TryParse(receivedMessage, out var linkId)) { Log.Info($"link id: {linkId}"); if (_identityLinker.TryMakeLink(linkId, user.Id, out var linkedSteamId)) { Log.Info($"linked steam ID: {linkedSteamId}"); var linkedPlayerName = MySession.Static.Players.TryGetIdentityNameFromSteamId(linkedSteamId); await channel.MentionAsync(user.Id, $"Alert linked to \"{linkedPlayerName}\"."); _chatManager.SendMessage("Alert", linkedSteamId, $"Alert linked to \"{user.Username}\"."); return; } await channel.MentionAsync(user.Id, $"Invalid input; not mapped: {linkId}"); return; } // no linked steam id found if (!_identityLinker.TryGetSteamId(user.Id, out var steamId)) { await channel.MentionAsync(user.Id, "Steam ID not linked"); return; } // delegate to listeners foreach (var messageListener in _messageListeners) { if (messageListener.TryRespond(steamId, receivedMessage, out var response)) { await channel.MentionAsync(user.Id, response); return; } } await channel.MentionAsync(user.Id, $"Unknown message: \"{receivedMessage}\""); }