private void Client_OnMessageReceived(object sender, OnMessageReceivedArgs e) { if (e.ChatMessage.Message.Contains("BadRolls")) { twitchClient.SendMessage(e.ChatMessage.Channel, "Did I hear someone say BadRolls?"); } if (e.ChatMessage.Message.StartsWith("!teams")) { twitchClient.SendMessage(e.ChatMessage.Channel, _sheetService.ListTeams(e.ChatMessage.Channel, e.ChatMessage.Username)); } }
private async Task DiscordMessageReceived(SocketMessage message) { if (message.Author.IsBot) { return; } var dmchannelID = await message.Author.GetOrCreateDMChannelAsync(); if (message.Channel.Id == dmchannelID.Id) { if (message.Content.ToLower().StartsWith("submit") || message.Content.ToLower().StartsWith("!submit") || message.Content.ToLower().StartsWith(".submit")) { try { var eventName = "undetermined"; var args = message.Content.Split(' '); switch (args[1].ToUpper()) { case "WDA": case "WEEKLY-DICE-ARENA": eventName = Refs.EVENT_WDA; break; case "DF": case "DICE-FIGHT": eventName = Refs.EVENT_DICE_FIGHT; break; case "TOTM": case "TEAM-OF-THE-MONTH": eventName = Refs.EVENT_TOTM; break; case "RFTN": case "ROLL-FOR-THE-NORTH": case "CANNATS": eventName = Refs.EVENT_ONEOFF; break; default: break; } await message.Channel.SendMessageAsync(SubmitTeamLink(eventName, args[2], message)); } catch (Exception exc) { Console.WriteLine($"Exception submitting team via DM: {exc.Message}"); await message.Channel.SendMessageAsync("Sorry, I was unable to determine which event you wanted to submit to."); await message.Channel.SendMessageAsync(Refs.DMBotSubmitTeamHint); await message.Channel.SendMessageAsync("If you think you're doing it right and it still doesn't work, message Yort or post in #bot-uprising"); } } else if (message.Content.ToLower().StartsWith("!win") || message.Content.ToLower().StartsWith(".win")) { try { var sheetsService = _sheetService.AuthorizeGoogleSheets(); string[] args = message.Content.Split(" "); ColumnInput ci = new ColumnInput { Column1Value = message.Author.Username, Column2Value = args[1] }; // record it in the spreadsheet await message.Channel.SendMessageAsync( _sheetService.SendLinkToGoogle(sheetsService, message, _sheetService.DiceFightSheetId, "WINSheet", ci)); await message.Channel.SendMessageAsync("Also, I hope to do this automatically soon, but I am already up to late, so would you mind terribly re-submitting your team so your WIN name gets recorded properly? Thanks, I reaZZZZZZZZZ"); // update current DiceFight sheet? } catch (Exception exc) { Console.WriteLine($"Exception in UpdateWinName: {exc.Message}"); await message.Channel.SendMessageAsync("Sorry, I was unable to record your WIN Name. Please contact Yort and tell him what went wrong"); } } else { await message.Channel.SendMessageAsync("Sorry, I don't understand that command. I'm not actually that smart, you know."); } return; } if (message.Content == "!ping") { await message.Channel.SendMessageAsync("Pong!"); } else if (message.Content.ToLower().StartsWith(SUBMIT_STRING) || message.Content.ToLower().StartsWith(".submit")) { // first delete the original message await message.Channel.DeleteMessageAsync(message); var teamlink = message.Content.TrimStart(SUBMIT_STRING.ToCharArray()).TrimStart(".submit".ToCharArray()).Trim(); await message.Channel.SendMessageAsync(SubmitTeamLink(message.Channel.Name, teamlink, message)); } else if (message.Content.ToLower().StartsWith(".format") || message.Content.ToLower().StartsWith("!format")) { await message.Channel.SendMessageAsync(GetCurrentFormat(message)); } else if (message.Content.ToLower().StartsWith(".count") || message.Content.ToLower().StartsWith("!count")) { await message.Channel.SendMessageAsync(_sheetService.GetCurrentPlayerCount(message)); } else if (message.Content.ToLower().StartsWith(".list") || message.Content.ToLower().StartsWith("!list")) { await message.Channel.SendMessageAsync(_sheetService.GetCurrentPlayerList(message)); } else if (message.Content.ToLower().StartsWith(".here") || message.Content.ToLower().StartsWith("!here")) { await message.Channel.SendMessageAsync(_sheetService.MarkPlayerHere(message)); } else if (message.Content.ToLower().StartsWith(".drop") || message.Content.ToLower().StartsWith("!drop")) { await message.Channel.SendMessageAsync(_sheetService.MarkPlayerDropped(message)); } else if (message.Content.ToLower().StartsWith(".teams")) { await message.Channel.SendMessageAsync(_sheetService.ListTeams(message)); } else if (message.Content.ToLower().StartsWith(".help") || message.Content.ToLower().StartsWith("!help")) { await message.Channel.SendMessageAsync(Refs.DMBotCommandHelpString); } else if (message.Content.StartsWith("!test")) { var participants = await _challonge.GetAllParticipantsAsync("3a5g0n90"); Logger.LogDebug($"{participants.Count}"); } }