public override MessageResponse HandleMessage(string[] args, SocketUserMessage message) { if (args.Length != 1) { return(MessageResponse.NotHandled()); } if (args[0] != "!disconnect") { return(MessageResponse.NotHandled()); } using (var scope = _serviceProvider.CreateScope()) { var playerLogic = scope.ServiceProvider.GetRequiredService <IPlayerLogic>(); var fullName = message.Author.Username + "#" + message.Author.Discriminator; var result = playerLogic.DisconnectDiscordAccountByDiscordLogin(fullName); if (!result) { return(MessageResponse.Handled("Failed to disconnect your account: maybe it's not connected? If the problem persists, please contact Dotsent.")); } return(MessageResponse.HandledFormat("Your Discord account has been successfully disconnected. Please use !connect <player_name> if you want to reconnect.")); } }
public override MessageResponse HandleMessage(string[] args, SocketUserMessage message) { if (args.Length < 2) { return(MessageResponse.NotHandled()); } if (args[0] != "!admin") { return(MessageResponse.NotHandled()); } if (message.Author.Username != "Dotsent" || message.Author.DiscriminatorValue != 5616) { return(MessageResponse.NotHandled()); } if (args[1] == "officer") { if (args.Length < 3) { return(MessageResponse.NotHandled()); } var officerListService = _serviceProvider.GetRequiredService <IRegisteredDiscordUsersService>(); if (args[2] == "list") { var officerList = new StringBuilder(); foreach (var officer in officerListService.GetOfficers()) { officerList.AppendLine(officer); } return(MessageResponse.HandledFormat("Current officers in Discord: \n{0}", officerList)); } else if (args[2] == "add" && args.Length == 4) { var result = officerListService.AddOfficer(args[3]); if (result) { return(MessageResponse.Handled("Officer added OK.")); } return(MessageResponse.Handled("Officer addition failed.")); } else if (args[2] == "remove" && args.Length == 4) { var result = officerListService.RemoveOfficer(args[3]); if (result) { return(MessageResponse.Handled("Officer removed OK.")); } return(MessageResponse.Handled("Officer removal failed.")); } else if (args[2] == "reload") { officerListService.ReloadOfficers(); return(MessageResponse.Handled("Officer list reloaded from DB.")); } } else if (args[1] == "say") { if (args.Length < 4) { return(MessageResponse.NotHandled()); } ulong channelId = 0; var result = ulong.TryParse(args[2], out channelId); if (!result) { return(MessageResponse.Handled("Sorry, boss, can't parse the channel id!")); } return(MessageResponse.Handled(string.Join(' ', args.Skip(3)), channelId)); } return(MessageResponse.Handled("Sorry, boss, I don't get it!")); }